Fixed #5665: Recognize free() with more than one parameter
This commit is contained in:
parent
d52b031301
commit
4e5c5eb238
|
@ -257,7 +257,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getDeallocationType(const Token *tok
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
|
||||||
if (Token::Match(tok, "free|kfree ( %varid% ) [;:]", varid) ||
|
if (Token::Match(tok, "free|kfree ( %varid% ) [;:]", varid) ||
|
||||||
Token::Match(tok, "free|kfree ( %varid% -", varid) ||
|
Token::Match(tok, "free|kfree ( %varid% -|,", varid) ||
|
||||||
Token::Match(tok, "realloc ( %varid% , 0 ) ;", varid))
|
Token::Match(tok, "realloc ( %varid% , 0 ) ;", varid))
|
||||||
return Malloc;
|
return Malloc;
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ private:
|
||||||
TEST_CASE(simple7);
|
TEST_CASE(simple7);
|
||||||
TEST_CASE(simple9); // Bug 2435468 - member function "free"
|
TEST_CASE(simple9); // Bug 2435468 - member function "free"
|
||||||
TEST_CASE(simple11);
|
TEST_CASE(simple11);
|
||||||
|
TEST_CASE(nonstd_free);
|
||||||
TEST_CASE(new_nothrow);
|
TEST_CASE(new_nothrow);
|
||||||
|
|
||||||
TEST_CASE(staticvar);
|
TEST_CASE(staticvar);
|
||||||
|
@ -970,6 +971,13 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nonstd_free() {
|
||||||
|
check("void f() {\n"
|
||||||
|
" void* mem = malloc(100, foo);" // Non-standard malloc() implementation
|
||||||
|
" free(mem, bar);" // Non-standard free() implementation (#5665)
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void new_nothrow() {
|
void new_nothrow() {
|
||||||
|
|
Loading…
Reference in New Issue