Fixed #989 (CppCheck crashes on Win XP when scanning large directories/subdirectories)

This commit is contained in:
Daniel Marjamäki 2009-11-23 18:59:50 +01:00
parent 7596e76a79
commit 128b2b8c59
2 changed files with 4 additions and 1 deletions

View File

@ -3635,7 +3635,7 @@ void Tokenizer::elseif()
if (indent == 0 && Token::Match(tok2, "}|;"))
{
if (tok2->next()->str() != "else")
if (tok2->next() && tok2->next()->str() != "else")
{
tok->insertToken("{");
tok2->insertToken("}");

View File

@ -530,6 +530,9 @@ private:
{
const char code[] = "else if(ab) { cd } else { ef }gh";
ASSERT_EQUALS("\n\n##file 0\n1: else { if ( ab ) { cd } else { ef } } gh\n", elseif(code));
// syntax error: assert there is no segmentation fault
ASSERT_EQUALS("\n\n##file 0\n1: else if ( x ) { }\n", elseif("else if (x) { }"));
}