diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 31551764b7b..7c15be961bc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9018,8 +9018,8 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (Token::Match(tok, "? %assign%")) syntaxError(tok); - if (Token::Match(tok, "!|~ %comp%") && - !(cpp && tok->strAt(1) == ">" && Token::simpleMatch(tok->tokAt(-1), "operator"))) + if (Token::Match(tok, "[!~+-/] %comp%") && + !(cpp && Token::Match(tok->next(), "[<>]") && Token::simpleMatch(tok->tokAt(-1), "operator"))) syntaxError(tok); if (Token::Match(tok, "%comp% {") && (!cpp || tok->str() != ">")) syntaxError(tok); diff --git a/test/cli/fuzz-crash/crash-c540e04fe675639b7ead821efc2f5c037b6c89e0 b/test/cli/fuzz-crash/crash-c540e04fe675639b7ead821efc2f5c037b6c89e0 new file mode 100644 index 00000000000..f2fb80ecd28 --- /dev/null +++ b/test/cli/fuzz-crash/crash-c540e04fe675639b7ead821efc2f5c037b6c89e0 @@ -0,0 +1 @@ +o o(){i n;for(i x:v)n=n+<1;} diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 21a15082bc1..aaacfeda3ff 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -848,7 +848,7 @@ class TestGarbage : public TestFixture { } void garbageCode95() { // #6804 - ASSERT_THROW_INTERNAL(checkCode("{ } x x ; { } h h [ ] ( ) ( ) { struct x ( x ) ; int __attribute__ ( ) f ( ) { h - > first = & x ; struct x * n = h - > first ; ( ) n > } }"), AST); // do not crash + ASSERT_THROW_INTERNAL(checkCode("{ } x x ; { } h h [ ] ( ) ( ) { struct x ( x ) ; int __attribute__ ( ) f ( ) { h - > first = & x ; struct x * n = h - > first ; ( ) n > } }"), SYNTAX); // do not crash } void garbageCode96() { // #6807