Skip to content

Commit aa5262d

Browse files
Fix #13123/13124 fuzzing crashes (danmar#6909)
1 parent a49ed56 commit aa5262d

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

lib/tokenize.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8530,6 +8530,9 @@ void Tokenizer::findGarbageCode() const
85308530
else if (Token::Match(tok, "[({<] %assign%"))
85318531
syntaxError(tok);
85328532

8533+
else if (Token::Match(tok, "%assign% >"))
8534+
syntaxError(tok);
8535+
85338536
else if (Token::Match(tok, "[`\\@]"))
85348537
syntaxError(tok);
85358538

lib/tokenlist.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,10 @@ void TokenList::validateAst(bool print) const
18851885
throw InternalError(tok, "Syntax Error: AST broken, binary operator '" + tok->str() + "' doesn't have two operands.", InternalError::AST);
18861886
}
18871887

1888+
if (Token::Match(tok, "++|--") && !tok->astOperand1()) {
1889+
throw InternalError(tok, "Syntax Error: AST broken, operator '" + tok->str() + "' doesn't have an operand.", InternalError::AST);
1890+
}
1891+
18881892
// Check control blocks and asserts
18891893
if (Token::Match(tok->previous(), "if|while|for|switch|assert|ASSERT (")) {
18901894
if (!tok->astOperand1() || !tok->astOperand2())
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C(){o y=>::*}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
assert(a~--)

test/testpostfixoperator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ class TestPostfixOperator : public TestFixture {
305305
}
306306

307307
void test2168() {
308-
check("--> declare allocator lock here\n"
309-
"int main(){}");
310-
ASSERT_EQUALS("", errout_str());
308+
ASSERT_THROW_INTERNAL(check("--> declare allocator lock here\n"
309+
"int main(){}"),
310+
AST);
311311
}
312312

313313
void pointerSimplest() {

0 commit comments

Comments
 (0)