From: Andre Noll Date: Sun, 7 May 2023 18:04:19 +0000 (+0200) Subject: afs: Fix memory leak in mood_load(). X-Git-Tag: v0.7.3~22 X-Git-Url: http://git.tuebingen.mpg.de/versions/paraslash-0.3.1.tar.bz2.asc?a=commitdiff_plain;h=6e3e710015b0b2c208b80a91d5f7842482359db2;p=paraslash.git afs: Fix memory leak in mood_load(). If mood_load() manages to load the mood but does not find any admissible files, it does not deallocate the mood instance and does not set up the global current_mood variable either. Plug the resulting memory leak by destroying the mood also if there are no admissible files (ret == 0). --- diff --git a/mood.c b/mood.c index 9cdfd011..e85cf36a 100644 --- a/mood.c +++ b/mood.c @@ -630,9 +630,10 @@ int mood_load(const char *mood_name, char **msg) ret = aa.m->stats.num; mood_unload(); current_mood = aa.m; + ret = 1; out: free(aa.array); - if (ret < 0) + if (ret <= 0) /* error, or no admissible files */ destroy_mood(aa.m); return ret; }