parent
b6fa9bb5aa
commit
18a7a805df
|
@ -838,7 +838,7 @@ void CheckLeakAutoVar::changeAllocStatus(VarInfo *varInfo, const VarInfo::AllocI
|
|||
var->second.type = allocation.type;
|
||||
var->second.allocTok = allocation.allocTok;
|
||||
}
|
||||
} else if (allocation.status != VarInfo::NOALLOC && allocation.status != VarInfo::OWNED) {
|
||||
} else if (allocation.status != VarInfo::NOALLOC && allocation.status != VarInfo::OWNED && !Token::simpleMatch(tok->astTop(), "return")) {
|
||||
alloctype[arg->varId()].status = VarInfo::DEALLOC;
|
||||
alloctype[arg->varId()].allocTok = tok;
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ private:
|
|||
TEST_CASE(doublefree9);
|
||||
TEST_CASE(doublefree10); // #8706
|
||||
TEST_CASE(doublefree11);
|
||||
TEST_CASE(doublefree12); // #10502
|
||||
|
||||
// exit
|
||||
TEST_CASE(exit1);
|
||||
|
@ -1316,6 +1317,16 @@ private:
|
|||
ASSERT_EQUALS("[test.c:3] -> [test.c:8]: (error) Memory pointed to by 'p' is freed twice.\n", errout.str());
|
||||
}
|
||||
|
||||
void doublefree12() { // #10502
|
||||
check("int f(FILE *fp, const bool b) {\n"
|
||||
" if (b)\n"
|
||||
" return fclose(fp);\n"
|
||||
" fclose(fp);\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void exit1() {
|
||||
check("void f() {\n"
|
||||
" char *p = malloc(10);\n"
|
||||
|
|
Loading…
Reference in New Issue