Fixed #5236 (varid 0: vlc: src/misc/objects.c:126)
This commit is contained in:
parent
a4f9cb78d5
commit
9f62740e1d
|
@ -1099,7 +1099,7 @@ void CheckUninitVar::checkScope(const Scope* scope)
|
||||||
if (scope->function) {
|
if (scope->function) {
|
||||||
for (unsigned int i = 0; i < scope->function->argCount(); i++) {
|
for (unsigned int i = 0; i < scope->function->argCount(); i++) {
|
||||||
const Variable *arg = scope->function->getArgumentVar(i);
|
const Variable *arg = scope->function->getArgumentVar(i);
|
||||||
if (arg && Token::Match(arg->typeStartToken(), "struct| %type% * %var% [,)]")) {
|
if (arg && arg->declarationId() && Token::Match(arg->typeStartToken(), "struct| %type% * %var% [,)]")) {
|
||||||
// Treat the pointer as initialized until it is assigned by malloc
|
// Treat the pointer as initialized until it is assigned by malloc
|
||||||
for (const Token *tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
|
for (const Token *tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "[;{}] %varid% = %var% (", arg->declarationId()) &&
|
if (Token::Match(tok, "[;{}] %varid% = %var% (", arg->declarationId()) &&
|
||||||
|
|
|
@ -3285,6 +3285,12 @@ private:
|
||||||
" struct AB *ab = malloc(sizeof(struct AB));\n"
|
" struct AB *ab = malloc(sizeof(struct AB));\n"
|
||||||
" do_something(ab);\n"
|
" do_something(ab);\n"
|
||||||
"}");
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// analysis failed. varid 0.
|
||||||
|
checkUninitVar2("void *vlc_custom_create (vlc_object_t *parent, size_t length, const char *typename) {\n"
|
||||||
|
" assert (length >= sizeof (vlc_object_t));\n"
|
||||||
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue