Fix FP (regression): Resource handle 'fd' freed twice. [doubleFree] (#5424)
This commit is contained in:
parent
4fa1c7d5f9
commit
f9b18bc9d8
|
@ -281,7 +281,7 @@ static const Token * isFunctionCall(const Token * nameToken)
|
|||
nameToken = nameToken->link()->next();
|
||||
}
|
||||
// check for '('
|
||||
if (nameToken && nameToken->link() && nameToken->str() == "(") {
|
||||
if (nameToken && nameToken->link() && !nameToken->isCast() && nameToken->str() == "(") {
|
||||
// returning opening parenthesis pointer
|
||||
return nameToken;
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ private:
|
|||
TEST_CASE(doublefree12); // #10502
|
||||
TEST_CASE(doublefree13); // #11008
|
||||
TEST_CASE(doublefree14); // #9708
|
||||
TEST_CASE(doublefree15);
|
||||
|
||||
// exit
|
||||
TEST_CASE(exit1);
|
||||
|
@ -1528,6 +1529,13 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void doublefree15() { // #11966
|
||||
check("void f(FILE* fp) {\n"
|
||||
" static_cast<void>(fclose(fp));\n"
|
||||
"}", true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void exit1() {
|
||||
check("void f() {\n"
|
||||
" char *p = malloc(10);\n"
|
||||
|
|
Loading…
Reference in New Issue