fix again #3064 (false negative: returning address of stack variable)
This commit is contained in:
parent
ff690abf80
commit
2667e34a07
|
@ -168,7 +168,7 @@ void CheckAutoVariables::autoVariables()
|
|||
else if (Token::Match(tok, "return & %var% ;") && tok->tokAt(2)->varId())
|
||||
{
|
||||
const Variable * var1 = symbolDatabase->getVariableFromVarId(tok->tokAt(2)->varId());
|
||||
if (var1 && var1->isArgument() && var1->typeStartToken() == var1->typeEndToken())
|
||||
if (var1 && var1->isArgument())
|
||||
errorReturnAddressOfFunctionParameter(tok, tok->strAt(2));
|
||||
}
|
||||
// Invalid pointer deallocation
|
||||
|
|
|
@ -574,6 +574,13 @@ private:
|
|||
"}\n");
|
||||
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Return the address of function parameter 'y'\n", errout.str());
|
||||
|
||||
check("int ** foo(int * y)\n"
|
||||
"{\n"
|
||||
" return &y;\n"
|
||||
"}\n");
|
||||
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Return the address of function parameter 'y'\n", errout.str());
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue