CheckUninitVar: Fix a FP reported for invalid code
This commit is contained in:
parent
42ed436e9d
commit
1f5eea98b5
|
@ -1916,7 +1916,7 @@ int CheckUninitVar::isFunctionParUsage(const Token *vartok, bool pointer, Alloc
|
|||
return alloc == NO_ALLOC;
|
||||
} else {
|
||||
const bool isnullbad = _settings->library.isnullargbad(start->previous(), argumentNumber + 1);
|
||||
if (!address && isnullbad && alloc == NO_ALLOC)
|
||||
if (pointer && !address && isnullbad && alloc == NO_ALLOC)
|
||||
return true;
|
||||
const bool isuninitbad = _settings->library.isuninitargbad(start->previous(), argumentNumber + 1);
|
||||
if (alloc != NO_ALLOC)
|
||||
|
|
|
@ -1012,6 +1012,13 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// TODO: write a proper testcase, this can not be compiled
|
||||
checkUninitVar2("struct X { int x; };\n"
|
||||
"void f() {\n"
|
||||
" X var;\n"
|
||||
" memset(var, 0, sizeof(var));\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue