Fixed #6252 (False positive "freed twice")

--HG--
extra : rebase_source : 24f801452fbefa3a59ab2cca62c3cf02aea513b6
This commit is contained in:
Frank Zingsheim 2014-11-03 21:24:34 +01:00
parent 82a6c2cb50
commit 7e0fc3d481
2 changed files with 17 additions and 1 deletions

View File

@ -2112,6 +2112,8 @@ void CheckOther::checkDoubleFree()
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
const std::size_t functions = symbolDatabase->functionScopes.size();
for (std::size_t i = 0; i < functions; ++i) {
freedVariables.clear();
closeDirVariables.clear();
const Scope * scope = symbolDatabase->functionScopes[i];
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
// Keep track of any variables passed to "free()", "g_free()" or "closedir()",

View File

@ -5146,7 +5146,21 @@ private:
);
ASSERT_EQUALS("", errout.str());
check( // #6252
"struct Wrapper {\n"
" Thing* m_thing;\n"
" Wrapper() : m_thing(0) {\n"
" }\n"
" ~Wrapper() {\n"
" delete m_thing;\n"
" }\n"
" void changeThing() {\n"
" delete m_thing;\n"
" m_thing = new Thing;\n"
" }\n"
"};\n"
);
ASSERT_EQUALS("", errout.str());
}