fix #2682 (segmentation fault of cppcheck ( x a[0] = ))
This commit is contained in:
parent
ebd5a123ce
commit
3d4eb0d77e
|
@ -5877,7 +5877,7 @@ void Tokenizer::simplifyVarDecl()
|
|||
|
||||
tok2 = tok2->next();
|
||||
|
||||
if (tok2->str() == ";")
|
||||
if (tok2 && tok2->str() == ";")
|
||||
tok2 = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -352,6 +352,7 @@ private:
|
|||
TEST_CASE(removeUnnecessaryQualification2);
|
||||
|
||||
TEST_CASE(simplifyIfNotNull);
|
||||
TEST_CASE(simplifyVarDecl); // ticket # 2682 segmentation fault
|
||||
}
|
||||
|
||||
std::string tok(const char code[], bool simplify = true)
|
||||
|
@ -6983,7 +6984,13 @@ private:
|
|||
"}";
|
||||
ASSERT_EQUALS("void f ( int x ) { }", tok(code, false));
|
||||
}
|
||||
}
|
||||
|
||||
void simplifyVarDecl() // ticket # 2682 segmentation fault
|
||||
{
|
||||
const char code[] = "x a[0] =";
|
||||
tok(code, false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue