* Fix #5678 FN destructor with no definition hide mismatching allocation / deallocation * Format * Fix test * Format
This commit is contained in:
parent
35fba07910
commit
917496a844
|
@ -632,14 +632,14 @@ void CheckMemoryLeakInClass::variable(const Scope *scope, const Token *tokVarnam
|
||||||
if (destructor)
|
if (destructor)
|
||||||
deallocInDestructor = true;
|
deallocInDestructor = true;
|
||||||
|
|
||||||
// several types of allocation/deallocation?
|
|
||||||
if (memberDealloc != CheckMemoryLeak::No && memberDealloc != dealloc)
|
|
||||||
dealloc = CheckMemoryLeak::Many;
|
|
||||||
|
|
||||||
if (dealloc != CheckMemoryLeak::Many && memberAlloc != CheckMemoryLeak::No && memberAlloc != Many && memberAlloc != dealloc) {
|
if (dealloc != CheckMemoryLeak::Many && memberAlloc != CheckMemoryLeak::No && memberAlloc != Many && memberAlloc != dealloc) {
|
||||||
mismatchAllocDealloc({tok}, classname + "::" + varname);
|
mismatchAllocDealloc({tok}, classname + "::" + varname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// several types of allocation/deallocation?
|
||||||
|
if (memberDealloc != CheckMemoryLeak::No && memberDealloc != dealloc)
|
||||||
|
dealloc = CheckMemoryLeak::Many;
|
||||||
|
|
||||||
memberDealloc = dealloc;
|
memberDealloc = dealloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1571,6 +1571,18 @@ private:
|
||||||
" delete [] pkt_buffer;\n"
|
" delete [] pkt_buffer;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:14]: (error) Mismatching allocation and deallocation: A::pkt_buffer\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:14]: (error) Mismatching allocation and deallocation: A::pkt_buffer\n", errout.str());
|
||||||
|
|
||||||
|
check("struct S {\n" // 5678
|
||||||
|
" ~S();\n"
|
||||||
|
" void f();\n"
|
||||||
|
" int* p;\n"
|
||||||
|
"};\n"
|
||||||
|
"void S::f() {\n"
|
||||||
|
" p = new char[1];\n"
|
||||||
|
" delete p;\n"
|
||||||
|
" p = 0;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:8]: (error) Mismatching allocation and deallocation: S::p\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void mismatch2() { // #5659
|
void mismatch2() { // #5659
|
||||||
|
|
Loading…
Reference in New Issue