From 30e977fe4a01c7c080527f447e3968e524212239 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 10 Mar 2022 22:14:01 +0100 Subject: [PATCH] mp.c: Fix memory leak on parse errors. When mp_yyparse() fails we miss to free the abstract syntax tree. Found by valgrind. --- mp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mp.c b/mp.c index 416b4f92..aea767d9 100644 --- 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 -- 2.39.5