Skip to content

Commit 4cbffa4

Browse files
Fix #13210 fuzzing crash in getEnumType() (danmar#6907)
1 parent a68154f commit 4cbffa4

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

lib/tokenize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8747,6 +8747,8 @@ void Tokenizer::findGarbageCode() const
87478747
!(tok->tokType() == Token::Type::eBoolean && cpp && Token::simpleMatch(tok->tokAt(-1), "requires")))
87488748
syntaxError(tok);
87498749
}
8750+
if (Token::Match(tok, "( ) %num%|%bool%|%char%|%str%"))
8751+
syntaxError(tok);
87508752
if (Token::Match(tok, "%assign% typename|class %assign%"))
87518753
syntaxError(tok);
87528754
if (Token::Match(tok, "%assign% [;)}]") && (!cpp || !Token::simpleMatch(tok->previous(), "operator")))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{enum{A=s()0=s};}

test/testgarbage.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,7 @@ class TestGarbage : public TestFixture {
679679
}
680680

681681
void garbageCode48() { // #6712 (segmentation fault)
682-
(void)checkCode(" { d\" ) d ...\" } int main ( ) { ( ) catch ( A a ) { { } catch ( ) \"\" } }");
683-
ignore_errout(); // we do not care about the output
682+
ASSERT_THROW_INTERNAL(checkCode(" { d\" ) d ...\" } int main ( ) { ( ) catch ( A a ) { { } catch ( ) \"\" } }"), SYNTAX);
684683
}
685684

686685
void garbageCode49() { // #6715

0 commit comments

Comments
 (0)