parent
ec9dbb31f4
commit
ae27b613ae
|
@ -263,7 +263,7 @@ static bool isLocalVarNoAutoDealloc(const Token *varTok, const bool isCpp)
|
|||
// non-pod variable
|
||||
if (isCpp) {
|
||||
// Possibly automatically deallocated memory
|
||||
if (isAutoDealloc(var) && Token::Match(varTok, "%var% = new"))
|
||||
if (isAutoDealloc(var) && Token::Match(varTok, "%var% [=({] new"))
|
||||
return false;
|
||||
if (!var->isPointer() && !var->typeStartToken()->isStandardType())
|
||||
return false;
|
||||
|
|
|
@ -580,6 +580,20 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: p\n"
|
||||
"[test.cpp:4]: (error) Memory leak: q\n",
|
||||
errout.str());
|
||||
|
||||
check("struct S : B {\n" // #12239
|
||||
" void f();\n"
|
||||
" void g();\n"
|
||||
"};\n"
|
||||
"void S::f() {\n"
|
||||
" FD* fd(new FD(this));\n"
|
||||
" fd->exec();\n"
|
||||
"}\n"
|
||||
"void S::g() {\n"
|
||||
" FD* fd{ new FD(this) };\n"
|
||||
" fd->exec();\n"
|
||||
"}\n", true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void isAutoDealloc() {
|
||||
|
|
Loading…
Reference in New Issue