From a1e5f9c312e5a66088c1366642fb4c460fba9095 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);