]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
afs: Really fix memory leak in mood_load().
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 20 Jun 2023 21:05:10 +0000 (23:05 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 20 Jun 2023 21:05:10 +0000 (23:05 +0200)
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

diff --git a/mood.c b/mood.c
index 94ec3cd49ee3128348185d829acaa417fdbb5b5c..18c02f7fa2f0529175c4b84bfc73600354fa3211 100644 (file)
--- 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;
 }