Fixed #789 (false positive: resource leak reported when using for loop)
This commit is contained in:
parent
4a66edd408
commit
23d8937661
|
@ -916,7 +916,8 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
// Loops..
|
||||
else if ((tok->str() == "for") || (tok->str() == "while"))
|
||||
{
|
||||
if (Token::simpleMatch(tok, "while ( true )"))
|
||||
if (Token::simpleMatch(tok, "while ( true )") ||
|
||||
Token::simpleMatch(tok, "for ( ; ; )"))
|
||||
{
|
||||
addtoken("while1");
|
||||
tok = tok->next()->link();
|
||||
|
|
|
@ -361,6 +361,7 @@ private:
|
|||
ASSERT_EQUALS(";;loop{alloc;}", getcode("char *s; for (a;b;c) { s=malloc(10); }", "s"));
|
||||
ASSERT_EQUALS(";;do{}loop;", getcode("char *s; do { } while (a);", "s"));
|
||||
ASSERT_EQUALS(";;while1{}", getcode("char *s; while(true) { }", "s"));
|
||||
ASSERT_EQUALS(";;while1{}", getcode("char *s; for(;;) { }", "s"));
|
||||
|
||||
// asprintf..
|
||||
ASSERT_EQUALS(";;alloc;", getcode("char *s; asprintf(&s, \"xyz\");", "s"));
|
||||
|
|
Loading…
Reference in New Issue