parent
19f605c7e5
commit
4d44d0c079
|
@ -2136,13 +2136,6 @@ bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Setti
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isVariableChangedByFunctionCall(const Token* tok, int indirect, const Settings* settings)
|
|
||||||
{
|
|
||||||
bool inconclusive = false;
|
|
||||||
bool r = isVariableChangedByFunctionCall(tok, indirect, settings, &inconclusive);
|
|
||||||
return r || inconclusive;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isVariableChanged(const Token *tok, int indirect, const Settings *settings, bool cpp, int depth)
|
bool isVariableChanged(const Token *tok, int indirect, const Settings *settings, bool cpp, int depth)
|
||||||
{
|
{
|
||||||
if (!tok)
|
if (!tok)
|
||||||
|
|
|
@ -836,7 +836,7 @@ void CheckLeakAutoVar::changeAllocStatus(VarInfo *varInfo, const VarInfo::AllocI
|
||||||
var->second.type = allocation.type;
|
var->second.type = allocation.type;
|
||||||
var->second.allocTok = allocation.allocTok;
|
var->second.allocTok = allocation.allocTok;
|
||||||
}
|
}
|
||||||
} else if (allocation.status != VarInfo::NOALLOC) {
|
} else if (allocation.status != VarInfo::NOALLOC && allocation.status != VarInfo::OWNED) {
|
||||||
alloctype[arg->varId()].status = VarInfo::DEALLOC;
|
alloctype[arg->varId()].status = VarInfo::DEALLOC;
|
||||||
alloctype[arg->varId()].allocTok = tok;
|
alloctype[arg->varId()].allocTok = tok;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,7 @@ private:
|
||||||
TEST_CASE(deallocuse6); // #4034: FP. x = p = f();
|
TEST_CASE(deallocuse6); // #4034: FP. x = p = f();
|
||||||
TEST_CASE(deallocuse7); // #6467, #6469, #6473
|
TEST_CASE(deallocuse7); // #6467, #6469, #6473
|
||||||
TEST_CASE(deallocuse8); // #1765
|
TEST_CASE(deallocuse8); // #1765
|
||||||
|
TEST_CASE(deallocuse9); // #9781
|
||||||
|
|
||||||
TEST_CASE(doublefree1);
|
TEST_CASE(doublefree1);
|
||||||
TEST_CASE(doublefree2);
|
TEST_CASE(doublefree2);
|
||||||
|
@ -696,6 +697,15 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Dereferencing 'ptr' after it is deallocated / released\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Dereferencing 'ptr' after it is deallocated / released\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void deallocuse9() { // #9781
|
||||||
|
check("void f(Type* p) {\n"
|
||||||
|
" std::shared_ptr<Type> sp(p);\n"
|
||||||
|
" bool b = p->foo();\n"
|
||||||
|
" return b;\n"
|
||||||
|
"}\n", /*cpp*/ true);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void doublefree1() { // #3895
|
void doublefree1() { // #3895
|
||||||
check("void f(char *p) {\n"
|
check("void f(char *p) {\n"
|
||||||
" if (x)\n"
|
" if (x)\n"
|
||||||
|
|
Loading…
Reference in New Issue