Fixed #2142 (false positive: null pointer dereference (throw))

This commit is contained in:
Daniel Marjamäki 2010-10-27 19:38:42 +02:00
parent b6aca47e11
commit fd153eac02
2 changed files with 9 additions and 1 deletions

View File

@ -2562,7 +2562,7 @@ void CheckOther::nullPointerByCheckAndDeRef()
} }
} }
if (Token::Match(tok2, "goto|return|continue|break|if")) if (Token::Match(tok2, "goto|return|continue|break|throw|if"))
{ {
if (Token::Match(tok2, "return * %var%")) if (Token::Match(tok2, "return * %var%"))
nullPointerError(tok2, tok->strAt(3)); nullPointerError(tok2, tok->strAt(3));

View File

@ -1189,6 +1189,14 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkNullPointer("void foo(char *p) {\n"
" if (!p) {\n"
" throw x;\n"
" }\n"
" *p = 0;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
void checkUninitVar(const char code[]) void checkUninitVar(const char code[])