From c04557eb73efad08bb6ac481a8f58e387371f218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 25 Jan 2018 15:53:58 +0100 Subject: [PATCH] Fix crashes detected with fuzzing --- lib/tokenize.cpp | 2 ++ test/testgarbage.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index ca852ca5d..2fa24b503 100755 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8362,6 +8362,8 @@ const Token * Tokenizer::findGarbageCode() const return tok; if (Token::Match(tok, ";|(|[ %comp%")) return tok; + if (Token::Match(tok, "%cop%|= ]") && tok->str() != "&") + return tok; } // Code must not start with an arithmetical operand diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 18497629b..ef642f9fb 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -1205,6 +1205,7 @@ private: ASSERT_THROW(checkCode("void f() { x= name2 & name3 name2 = | 0.1 , | 0.1 , | 0.1 name4 <= >( ); }"), InternalError); ASSERT_THROW(checkCode("void f() { x = , * [ | + 0xff | > 0xff]; }"), InternalError); ASSERT_THROW(checkCode("void f() { x = , | 0xff , 0.1 < ; }"), InternalError); + ASSERT_THROW(checkCode("void f() { x = [ 1 || ] ; }"), InternalError); } void garbageValueFlow() {