Fixed #5657 (false positive: (error) Possible null pointer dereference: p)

This commit is contained in:
Daniel Marjamäki 2014-04-28 15:54:54 +02:00
parent 3300d39854
commit 1233d8e47f
2 changed files with 8 additions and 1 deletions

View File

@ -723,7 +723,7 @@ static void execute(const Token *expr,
else if (expr->str() == "=") {
execute(expr->astOperand2(), programMemory, result, error);
if (expr->astOperand1() && expr->astOperand1()->varId())
if (!*error && expr->astOperand1() && expr->astOperand1()->varId())
(*programMemory)[expr->astOperand1()->varId()] = *result;
else
*error = true;

View File

@ -743,6 +743,13 @@ private:
" 0 : a[x];\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
code = "void f() {\n"
" int x;\n"
" for (int i = 0; x = bar[i]; i++)\n"
" x;\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
}
void valueFlowSubFunction() {