]> git.tue.mpg.de Git - paraslash.git/commitdiff
mp.c: Fix memory leak on parse errors.
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 10 Mar 2022 21:14:01 +0000 (22:14 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 12 Mar 2022 15:47:08 +0000 (16:47 +0100)
When mp_yyparse() fails we miss to free the abstract syntax tree.

Found by valgrind.

mp.c

diff --git a/mp.c b/mp.c
index 416b4f92065ef79716e7f966c3102e995071a112..aea767d99fea4b7bf0954504a03602766831a3b9 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -510,6 +510,7 @@ int mp_init(const char *definition, int nbytes, struct mp_context **result,
        mp_yy_delete_buffer(buffer_state, scanner);
        mp_yylex_destroy(scanner);
        if (ctx->errmsg) { /* parse error */
+               mp_free_ast(ctx->ast);
                if (errmsg)
                        *errmsg = ctx->errmsg;
                else