From: Andre Noll Date: Tue, 20 Jun 2023 21:05:10 +0000 (+0200) Subject: afs: Really fix memory leak in mood_load(). X-Git-Tag: v0.7.3~12^2 X-Git-Url: http://git.tuebingen.mpg.de/versions/paraslash-0.3.1.tar.bz2.asc?a=commitdiff_plain;h=ab4c39c7cd1c6d2b03cedf5d83521c746433367b;p=paraslash.git 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 --- 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; }