Fixed #785 (False positive: resource leak of extern FILE*)

This commit is contained in:
Daniel Marjamäki 2009-10-04 14:24:41 +02:00
parent b9cae72b6b
commit 6b1fae75e5
2 changed files with 13 additions and 2 deletions

View File

@ -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..

View File

@ -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()