Fixed #6252 (False positive "freed twice")
--HG-- extra : rebase_source : 24f801452fbefa3a59ab2cca62c3cf02aea513b6
This commit is contained in:
parent
82a6c2cb50
commit
7e0fc3d481
|
@ -2112,6 +2112,8 @@ void CheckOther::checkDoubleFree()
|
||||||
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
for (std::size_t i = 0; i < functions; ++i) {
|
||||||
|
freedVariables.clear();
|
||||||
|
closeDirVariables.clear();
|
||||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||||
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
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()",
|
// Keep track of any variables passed to "free()", "g_free()" or "closedir()",
|
||||||
|
|
|
@ -5146,7 +5146,21 @@ private:
|
||||||
);
|
);
|
||||||
ASSERT_EQUALS("", errout.str());
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue