From: Andre Noll Date: Thu, 10 Mar 2022 20:32:22 +0000 (+0100) Subject: mood.c: Fix memory leak in error path of load_mood(). X-Git-Tag: v0.7.0~2 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=c88ccb7d91ea4baab78e24922d5c1d0cbaf6dcce;p=paraslash.git mood.c: Fix memory leak in error path of load_mood(). When an existing mood definition happens to be invalid so that mp_init() fails, we return negative and leak the mood structure just allocated. This bug was introduced by the commit which removed version 1 moods. It was found by code inspection. Fixes: 184ea897a9b4 --- diff --git a/mood.c b/mood.c index e0d9e275..fbc22297 100644 --- a/mood.c +++ b/mood.c @@ -163,6 +163,8 @@ static int load_mood(const struct osl_row *mood_row, struct mood **m, PARA_INFO_LOG("opening mood %s\n", mood_name); ret = mp_init(mood_def.data, mood_def.size, &(*m)->parser_context, errmsg); osl_close_disk_object(&mood_def); + if (ret < 0) + destroy_mood(*m); return ret; }