Fix false positive nullPointer messages within sqlite3 after goto by adding a suitable bailout inside valueFlowAfterAssign()

This commit is contained in:
Alexander Mai 2014-04-26 14:41:28 +02:00
parent 11856b51aa
commit b74e997435
2 changed files with 12 additions and 1 deletions

View File

@ -612,7 +612,7 @@ static void valueFlowAfterAssign(TokenList *tokenlist, ErrorLogger *errorLogger,
tok2 = tok2->linkAt(2);
}
else if (indentlevel <= 0 && Token::Match(tok2, "break|continue")) {
else if (indentlevel <= 0 && Token::Match(tok2, "break|continue|goto")) {
if (settings->debugwarnings)
bailout(tokenlist, errorLogger, tok2, "variable " + var->nameToken()->str() + ". noreturn conditional scope.");
break;

View File

@ -623,6 +623,17 @@ private:
"}";
ASSERT_EQUALS(false, testValueOfX(code, 7U, 0));
code = "void f () {\n"
" ST * x = g_pST;\n"
" if (x->y == 0) {\n"
" x = NULL;\n"
" goto label;\n"
" }\n"
" a = x->y;\n"
"label:\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 7U, 0));
// multivariables
code = "void f(int a) {\n"
" int x = a;\n"