From: Andre Noll Date: Wed, 19 Mar 2025 23:18:30 +0000 (+0100) Subject: Teach the mood parser to not leak on errors. X-Git-Url: https://git.tuebingen.mpg.de/?a=commitdiff_plain;h=726924917d84060e932b379dba6519e78cd8e79e;p=paraslash.git Teach the mood parser to not leak on errors. Attempting to load an incomplete mood definition such as "1 &&" currently causes memory leaks because the memory for the partial syntax tree is never freed. Employ bison's %destructor directive to call mp_free_ast() whenever a syntax error happens. --- diff --git a/yy/mp.y b/yy/mp.y index dc04488f..f2f0756d 100644 --- a/yy/mp.y +++ b/yy/mp.y @@ -350,6 +350,9 @@ bool mp_eval_ast(struct mp_ast_node *root, struct mp_context *ctx) %type exp %type boolexp +/* Called when a symbol is automatically discarded due to a syntax error. */ +%destructor {mp_free_ast($$);} string exp boolexp + %% program: