Fixed #1063 (False positive: deallocated memory doesn't leak upon exception)
This commit is contained in:
parent
f5849f9be2
commit
e5c507dc02
|
@ -193,6 +193,15 @@ void CheckExceptionSafety::unsafeNew()
|
||||||
if (tok->next()->varId() && localVars.find(tok->next()->varId()) != localVars.end())
|
if (tok->next()->varId() && localVars.find(tok->next()->varId()) != localVars.end())
|
||||||
varname = tok->strAt(1);
|
varname = tok->strAt(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (tok->str() == "delete")
|
||||||
|
{
|
||||||
|
if (Token::simpleMatch(tok->next(), varname.c_str()) ||
|
||||||
|
Token::simpleMatch(tok->next(), ("[ ] " + varname).c_str()))
|
||||||
|
{
|
||||||
|
varname = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,15 @@ private:
|
||||||
" A *a2 = new (std::nothrow) A;\n"
|
" A *a2 = new (std::nothrow) A;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void a()\n"
|
||||||
|
"{\n"
|
||||||
|
" A *a1 = new A;\n"
|
||||||
|
" delete a1;\n"
|
||||||
|
" A *a2 = new A;\n"
|
||||||
|
" delete a2;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void realloc()
|
void realloc()
|
||||||
|
|
Loading…
Reference in New Issue