Fixed #5502 (FP: Dereferencing 'b' after it is deallocated / released)

This commit is contained in:
Daniel Marjamäki 2014-04-06 18:45:24 +02:00
parent 2328704ca2
commit d7e2e3bd5e
2 changed files with 4 additions and 1 deletions

View File

@ -582,7 +582,8 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
tok->str() == "realloc" ||
tok->str() == "return" ||
tok->str() == "switch" ||
tok->str() == "while") {
tok->str() == "while" ||
tok->str() == "sizeof") {
return 0;
}

View File

@ -517,6 +517,8 @@ private:
ASSERT_EQUALS(";;use_;", getcode("type *c; y = x + c->y;","c"));
ASSERT_EQUALS(";;use_;", getcode("type *c; y = c->y + x;","c"));
ASSERT_EQUALS(";;use_;", getcode("char *s; s = s + 1;", "s"));
ASSERT_EQUALS(";;dealloc;;", getcode("struct foo *s; free(s); printf(a,sizeof(*s));", "s"));
ASSERT_EQUALS(";;do{dealloc;;}while(var);", getcode("struct foo *s; do{free(s); printf(a,sizeof(*s));}while(s);", "s"));
// use reference
ASSERT_EQUALS(";;callfunc&use;", getcode("struct AB *ab; f(&ab);", "ab"));