Fix #796 (segmentation fault while scanning)

http://sourceforge.net/apps/trac/cppcheck/ticket/796
This commit is contained in:
Reijo Tomperi 2009-10-06 21:03:15 +03:00
parent 36fb24b1a5
commit 2e69d50458
2 changed files with 2 additions and 1 deletions

View File

@ -2940,7 +2940,7 @@ void Tokenizer::simplifyIfAssign()
// Skip the "%var% = ..."
Token *tok2;
unsigned int indentlevel = 0;
for (tok2 = tok; tok2; tok2 = tok2->next())
for (tok2 = tok->next(); tok2; tok2 = tok2->next())
{
if (tok2->str() == "(")
++indentlevel;

View File

@ -1188,6 +1188,7 @@ private:
ASSERT_EQUALS("; a = b ( ) ; if ( ( a ) ) { ; }", simplifyIfAssign(";if((a=b()));"));
ASSERT_EQUALS("; a = b ( ) ; if ( ! ( a ) ) { ; }", simplifyIfAssign(";if(!(a=b()));"));
ASSERT_EQUALS("; a . x = b ( ) ; if ( ! ( a . x ) ) { ; }", simplifyIfAssign(";if(!(a->x=b()));"));
ASSERT_EQUALS("A ( ) a = b ; if ( a ) { ; }", simplifyIfAssign("A() if(a=b);"));
}