Fixed #615 (Memleak was detected in 1.32 but not in 1.33 and later)
This commit is contained in:
parent
1dd2ec4757
commit
9d7defad22
|
@ -627,6 +627,13 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
||||||
if (parlevel == 0 && tok->str() == ";")
|
if (parlevel == 0 && tok->str() == ";")
|
||||||
addtoken(";");
|
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) ||
|
if (Token::Match(tok->previous(), "[(;{}] %varid% =", varid) ||
|
||||||
Token::Match(tok, "asprintf ( & %varid% ,", varid))
|
Token::Match(tok, "asprintf ( & %varid% ,", varid))
|
||||||
{
|
{
|
||||||
|
|
|
@ -366,6 +366,7 @@ private:
|
||||||
|
|
||||||
// assign..
|
// assign..
|
||||||
ASSERT_EQUALS(";;assign;", getcode("char *s; s = 0;", "s"));
|
ASSERT_EQUALS(";;assign;", getcode("char *s; s = 0;", "s"));
|
||||||
|
ASSERT_EQUALS(";;;", getcode("char *s; s = strcpy(s, p);", "s"));
|
||||||
|
|
||||||
// callfunc..
|
// callfunc..
|
||||||
ASSERT_EQUALS(";;assign" "callfunc;", getcode("char *s; s = a();", "s"));
|
ASSERT_EQUALS(";;assign" "callfunc;", getcode("char *s; s = a();", "s"));
|
||||||
|
|
Loading…
Reference in New Issue