]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mood.c
mood.c: Fix memory leak in change_current_mood().
[paraslash.git] / mood.c
diff --git a/mood.c b/mood.c
index d6a8292340aba7f48fb7816f96d9e9c0f672f210..4e0a7e3ddca78ed0e274cd2afba792fe767e25c3 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -903,7 +903,7 @@ int change_current_mood(const char *mood_name, char **errmsg)
        if (ret < 0) {
                if (errmsg)
                        *errmsg = make_message("audio file loop failed");
-               return ret;
+               goto out;
        }
        for (i = 0; i < statistics.num; i++) {
                struct admissible_file_info *a = aa.array + i;
@@ -919,6 +919,8 @@ int change_current_mood(const char *mood_name, char **errmsg)
        ret = statistics.num;
 out:
        free(aa.array);
+       if (ret < 0)
+               close_current_mood();
        return ret;
 }