Fixed #2582 (segmentation fault of cppcheck ( if() ))

This commit is contained in:
Daniel Marjamäki 2011-02-18 20:05:44 +01:00
parent 0e34b8bee5
commit 9a760b9654
2 changed files with 4 additions and 1 deletions

View File

@ -554,7 +554,7 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
{
// goto the end paranthesis
const Token *endpar = tok->next()->link();
const Token *endbody = endpar ? endpar->next()->link() : 0;
const Token *endbody = Token::simpleMatch(endpar, ") {") ? endpar->next()->link() : 0;
if (endbody &&
Token::Match(endbody->tokAt(-3), "[;{}] %var% ;") &&
isUpper(endbody->tokAt(-2)->str()))

View File

@ -890,6 +890,9 @@ private:
" };\n"
"}");
ASSERT_EQUALS("", errout.str());
// #2582 - segmentation fault
check("if()");
}
// Test CheckNullPointer::nullConstantDereference