Fixed #785 (False positive: resource leak of extern FILE*)
This commit is contained in:
parent
b9cae72b6b
commit
6b1fae75e5
|
@ -1947,8 +1947,8 @@ void CheckMemoryLeakInFunction::check()
|
|||
if (!Token::Match(tok, "[{};] %type%"))
|
||||
continue;
|
||||
|
||||
// Don't check static variables
|
||||
if (tok->next()->str() == "static")
|
||||
// Don't check static/extern variables
|
||||
if (Token::Match(tok->next(), "static|extern"))
|
||||
continue;
|
||||
|
||||
// return/else is not part of a variable declaration..
|
||||
|
|
|
@ -138,6 +138,7 @@ private:
|
|||
TEST_CASE(new_nothrow);
|
||||
|
||||
TEST_CASE(staticvar);
|
||||
TEST_CASE(externvar);
|
||||
|
||||
TEST_CASE(alloc_alloc_1);
|
||||
|
||||
|
@ -701,6 +702,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void externvar()
|
||||
{
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" extern char *s;\n"
|
||||
" s = malloc(100);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void alloc_alloc_1()
|
||||
|
|
Loading…
Reference in New Issue