Fixed ticket #3512 (segmentation fault of cppcheck ( 1 *p = const))
This commit is contained in:
parent
37f3aa1528
commit
6a248c35b5
|
@ -775,7 +775,7 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
|
|||
}
|
||||
|
||||
if (Token::simpleMatch(tok->previous(), "* 1") || Token::simpleMatch(tok, "1 *")) {
|
||||
if (tok->previous()->isOp())
|
||||
if (tok->previous() && tok->previous()->isOp())
|
||||
tok = tok->previous();
|
||||
tok->deleteNext();
|
||||
tok->deleteThis();
|
||||
|
|
|
@ -5900,6 +5900,8 @@ private:
|
|||
tokenizeAndStringify("int f(int a) { return 0 * a; }", true));
|
||||
ASSERT_EQUALS("bool f ( int i ) { switch ( i ) { case 15 : ; return true ; } }",
|
||||
tokenizeAndStringify("bool f(int i) { switch (i) { case 10 + 5: return true; } }", true));
|
||||
// ticket #3512 - Don't crash on garbage code
|
||||
ASSERT_EQUALS("p = const", tokenizeAndStringify("1 *p = const", true));
|
||||
}
|
||||
|
||||
void simplifyCompoundAssignment() {
|
||||
|
|
Loading…
Reference in New Issue