]> git.tue.mpg.de Git - paraslash.git/commitdiff
afs: Fix memory leak in mood_load().
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 12 Jun 2023 23:42:39 +0000 (01:42 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 18 Jun 2023 13:17:25 +0000 (15:17 +0200)
In the result != NULL case we open a fresh score table but miss to
close it if add_to_score_table() fails. This should never happen,
but still..

Fixes: 2d2637cb4c9ab76fea6bc336b9af88fd00bf5e08
mood.c

diff --git a/mood.c b/mood.c
index ddd2f1ccbc6e8be35797b9d1612fdab6d61e3979..94ec3cd49ee3128348185d829acaa417fdbb5b5c 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -663,8 +663,11 @@ int mood_load(const char *mood_name, struct mood_instance **result, char **msg)
        }
 out:
        free(aa.array);
-       if (ret < 0)
+       if (ret < 0) {
+               if (aa.m->score_table)
+                       score_close(aa.m->score_table);
                destroy_mood(aa.m);
+       }
        return ret;
 }