Fixed #1087 (uninitialized data not detected 'char z = *str')
This commit is contained in:
parent
461d826eff
commit
ae3ff7d376
|
@ -1722,7 +1722,7 @@ private:
|
||||||
|
|
||||||
if (Token::Match(tok.tokAt(-2), "[,(=] *"))
|
if (Token::Match(tok.tokAt(-2), "[,(=] *"))
|
||||||
{
|
{
|
||||||
use(foundError, checks, &tok);
|
use_pointer(foundError, checks, &tok);
|
||||||
return &tok;
|
return &tok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1744,6 +1744,12 @@ private:
|
||||||
use_array(foundError, checks, *it);
|
use_array(foundError, checks, *it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (Token::Match(&tok, "! %var% )"))
|
||||||
|
{
|
||||||
|
use(foundError, checks, &tok);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return ExecutionPath::parseCondition(tok, checks);
|
return ExecutionPath::parseCondition(tok, checks);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1403,6 +1403,15 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("void f()\n"
|
||||||
|
"{\n"
|
||||||
|
" char *s = malloc(100);\n"
|
||||||
|
" if (!s)\n"
|
||||||
|
" return;\n"
|
||||||
|
" char c = *s;\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:6]: (error) Data is allocated but not initialized: s\n", errout.str());
|
||||||
|
|
||||||
// struct..
|
// struct..
|
||||||
checkUninitVar("void f()\n"
|
checkUninitVar("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue