FIxed #3581 (double free false positive when exception rethrown)
This commit is contained in:
parent
2ff592e8d9
commit
8f827aa65f
|
@ -2533,7 +2533,7 @@ void CheckOther::checkDoubleFree()
|
|||
|
||||
// Any control statements in-between delete, free() or closedir() statements
|
||||
// makes it unclear whether any subsequent statements would be redundant.
|
||||
if (Token::Match(tok, "else|break|continue|goto|return")) {
|
||||
if (Token::Match(tok, "else|break|continue|goto|return|throw")) {
|
||||
freedVariables.clear();
|
||||
closeDirVariables.clear();
|
||||
}
|
||||
|
|
|
@ -4596,6 +4596,24 @@ private:
|
|||
"}"
|
||||
);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check(
|
||||
"void bug()"
|
||||
"{"
|
||||
" int* ptr = NULL;"
|
||||
" try"
|
||||
" {"
|
||||
" ptr = new int(4);"
|
||||
" }"
|
||||
" catch(...)"
|
||||
" {"
|
||||
" delete ptr;"
|
||||
" throw;"
|
||||
" }"
|
||||
" delete ptr;"
|
||||
"}"
|
||||
);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void coutCerrMisusage() {
|
||||
|
|
Loading…
Reference in New Issue