From c88ccb7d91ea4baab78e24922d5c1d0cbaf6dcce Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 10 Mar 2022 21:32:22 +0100 Subject: [PATCH] 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 --- mood.c | 2 ++ 1 file changed, 2 insertions(+) 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; } -- 2.39.5