Fixed #4175 (segmentation fault of cppcheck)

This commit is contained in:
Daniel Marjamäki 2012-09-09 18:56:26 +02:00
parent cf8ac78069
commit d3bdd84d8b
2 changed files with 3 additions and 1 deletions

View File

@ -1072,7 +1072,7 @@ void CheckUninitVar::checkScope(const Scope* scope)
bool stdtype = _tokenizer->isC();
const Token* tok = i->typeStartToken();
for (; tok->str() != ";" && tok->str() != "<"; tok = tok->next()) {
for (; tok && tok->str() != ";" && tok->str() != "<"; tok = tok->next()) {
if (tok->isStandardType())
stdtype = true;
}

View File

@ -2126,6 +2126,8 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar2(">{ x while (y) z int = }"); // #4175 : don't crash
// try
checkUninitVar2("void f() {\n"
" int i, *p = &i;\n"