From ab4c39c7cd1c6d2b03cedf5d83521c746433367b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 20 Jun 2023 23:05:10 +0200 Subject: [PATCH] afs: Really fix memory leak in mood_load(). The previous fix was insufficient as we also have to destroy the score table in the success case, so move the freeing to destroy_mood(). Fixes: bb0aec0963b1b2da617aebda26deca576684436c --- mood.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mood.c b/mood.c index 94ec3cd4..18c02f7f 100644 --- a/mood.c +++ b/mood.c @@ -134,6 +134,8 @@ static void destroy_mood(struct mood_instance *m) if (!m) return; mp_shutdown(m->parser_context); + if (m->score_table) + score_close(m->score_table); free(m->name); free(m); } @@ -663,11 +665,8 @@ int mood_load(const char *mood_name, struct mood_instance **result, char **msg) } out: free(aa.array); - if (ret < 0) { - if (aa.m->score_table) - score_close(aa.m->score_table); + if (ret < 0) destroy_mood(aa.m); - } return ret; } -- 2.39.2