FIxed #3581 (double free false positive when exception rethrown)

This commit is contained in:
Zachary Blair 2012-02-04 11:24:40 -08:00
parent 2ff592e8d9
commit 8f827aa65f
2 changed files with 19 additions and 1 deletions

View File

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

View File

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