Fixed #615 (Memleak was detected in 1.32 but not in 1.33 and later)

This commit is contained in:
Daniel Marjamäki 2009-08-29 17:33:57 +02:00
parent 1dd2ec4757
commit 9d7defad22
2 changed files with 8 additions and 0 deletions

View File

@ -627,6 +627,13 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
if (parlevel == 0 && tok->str() == ";")
addtoken(";");
// var = strcpy|.. ( var ,
if (Token::Match(tok, "[;{}] %varid% = memcpy|memmove|memset|strcpy|strncpy|strcat|strncat ( %varid% ,", varid))
{
tok = tok->tokAt(4)->link();
continue;
}
if (Token::Match(tok->previous(), "[(;{}] %varid% =", varid) ||
Token::Match(tok, "asprintf ( & %varid% ,", varid))
{

View File

@ -366,6 +366,7 @@ private:
// assign..
ASSERT_EQUALS(";;assign;", getcode("char *s; s = 0;", "s"));
ASSERT_EQUALS(";;;", getcode("char *s; s = strcpy(s, p);", "s"));
// callfunc..
ASSERT_EQUALS(";;assign" "callfunc;", getcode("char *s; s = a();", "s"));