ValueFlow: Fixed false positives after escape scope
This commit is contained in:
parent
223ceeb97f
commit
78c02f0505
|
@ -2610,7 +2610,7 @@ static bool valueFlowForwardVariable(Token* const startToken,
|
|||
// goto '}'
|
||||
tok2 = startToken1->link();
|
||||
|
||||
if (isReturnScope(tok2, settings) || !vfresult) {
|
||||
if (isEscapeScope(startToken1, tokenlist, true) || !vfresult) {
|
||||
if (condAlwaysTrue)
|
||||
return false;
|
||||
removeValues(values, truevalues);
|
||||
|
@ -2638,7 +2638,7 @@ static bool valueFlowForwardVariable(Token* const startToken,
|
|||
// goto '}'
|
||||
tok2 = startTokenElse->link();
|
||||
|
||||
if (isReturnScope(tok2, settings) || !vfresult) {
|
||||
if (isEscapeScope(startTokenElse, tokenlist, true) || !vfresult) {
|
||||
if (condAlwaysFalse)
|
||||
return false;
|
||||
removeValues(values, falsevalues);
|
||||
|
|
|
@ -551,6 +551,14 @@ private:
|
|||
" IF(!fred){}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo() {\n"
|
||||
" BUFFER *buffer = get_buffer();\n"
|
||||
" if (!buffer)\n"
|
||||
" uv_fatal_error();\n"
|
||||
" buffer->x = 11;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// Dereferencing a pointer and then checking if it is null
|
||||
|
|
Loading…
Reference in New Issue