* Fix #10857 FN: leakNoVarFunctionCall * Fix TODO * Fix #10858 FN: leakNoVarFunctionCall (if ( b && malloc ) )
This commit is contained in:
parent
88bf11abba
commit
e7e23e87c2
|
@ -1070,7 +1070,7 @@ void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope)
|
|||
if (closingBrace->str() == "}" && Token::Match(closingBrace->link()->tokAt(-1), "%name%") && (!isNew && precedes(tok, closingBrace->link())))
|
||||
continue;
|
||||
returnValueNotUsedError(tok, tok->str());
|
||||
} else if (Token::Match(parent, "%comp%|!|,")) {
|
||||
} else if (Token::Match(parent, "%comp%|!|,|%oror%|&&")) {
|
||||
if (!(parent->astParent() && parent->str() == ","))
|
||||
returnValueNotUsedError(tok, tok->str());
|
||||
}
|
||||
|
|
|
@ -2601,6 +2601,12 @@ private:
|
|||
" C{ new QWidget, 1 };\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(bool b) { if (b && malloc(42)) {} }\n" // // #10858
|
||||
"void g(bool b) { if (b || malloc(42)) {} }\n");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) Return value of allocation function 'malloc' is not stored.\n"
|
||||
"[test.cpp:2]: (error) Return value of allocation function 'malloc' is not stored.\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void smartPointerFunctionParam() {
|
||||
|
|
Loading…
Reference in New Issue