From 692ce7b3951809635b9b1175f59436cbf8d647ef Mon Sep 17 00:00:00 2001 From: Scott Vokes Date: Thu, 16 Feb 2023 17:53:41 -0500 Subject: [PATCH] parser.act: Avoid crash in parser from '(*:'. See #386 on katef/libfsm. This is a workaround for a bug in the parser -- once the fuzzer finds it, it tends to get in the way of finding deeper issues. --- src/libre/parser.act | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libre/parser.act b/src/libre/parser.act index abcc28be8..91d10913f 100644 --- a/src/libre/parser.act +++ b/src/libre/parser.act @@ -1095,6 +1095,17 @@ err->e = RE_ESUCCESS; ADVANCE_LEXER; + +#define BUILD_FOR_FUZZER 0 +#if BUILD_FOR_FUZZER + /* these errors currently are not handled properly */ + if (act_state->lex_tok == TOK_ERROR) { + fprintf(stderr, "syntax error\n"); + lx->free(lx->buf_opaque); + goto error; + } +#endif + DIALECT_ENTRY(&flags, lex_state, act_state, err, &ast->expr); lx->free(lx->buf_opaque);