Skip to content

Commit cad91da

Browse files
Fix #14742 fuzzing crash (stack-overflow) in CheckNullPointer::nullPointerByDeRefAndCheck() (#8693)
1 parent c9cb62f commit cad91da

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/tokenlist.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,8 +1951,11 @@ void TokenList::validateAst(bool print) const
19511951
if (tok->str() == "?") {
19521952
if (!tok->astOperand1() || !tok->astOperand2())
19531953
throw InternalError(tok, "AST broken, ternary operator missing operand(s)", InternalError::AST);
1954-
if (tok->astOperand2()->str() != ":")
1954+
const Token* colon = tok->astOperand2();
1955+
if (colon->str() != ":")
19551956
throw InternalError(tok, "Syntax Error: AST broken, ternary operator lacks ':'.", InternalError::AST);
1957+
if ((colon->astOperand1() && !precedes(colon->astOperand1(), colon)) || !succeeds(colon->astOperand2(), colon))
1958+
throw InternalError(tok, "AST broken, ternary operator has bad operand(s)", InternalError::AST);
19561959
}
19571960

19581961
// Check for endless recursion

test/cli/fuzz-crash_c/14742

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
i(){b?8:{}!$}

0 commit comments

Comments
 (0)