Uninitialized variables; avoid false positives when passing uninitialized variable to unknown function

This commit is contained in:
Daniel Marjamäki 2021-05-24 15:54:09 +02:00
parent a2e709a652
commit fa72ec20b2
2 changed files with 8 additions and 0 deletions

View File

@ -1511,6 +1511,8 @@ void CheckUninitVar::valueFlowUninit()
continue;
if (v->indirect > 1 || v->indirect < 0)
continue;
if (v->indirect == 0 && tok->valueType() && tok->valueType()->pointer == 0 && !isVariableUsage(tok, false, NO_ALLOC, 0))
continue;
bool uninitderef = false;
if (tok->variable()) {
bool unknown;

View File

@ -4601,6 +4601,12 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
valueFlowUninit("void json_parse_nat_type_flags(json_t *root) {\n"
" int index;\n"
" json_array_foreach(root, index, value) {}\n"
"}");
ASSERT_EQUALS("", errout.str());
valueFlowUninit("int foo()\n"
"{\n"
" int i;\n"