From: Andre Noll Date: Mon, 25 Nov 2024 23:28:53 +0000 (+0100) Subject: Fix memory leak in playlist.c. X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=8bd72ff8b3c9b59b3800042782a3fd28a65abddc;p=paraslash.git Fix memory leak in playlist.c. If the result pointer is NULL. we currently leak one playlist instance structure (12 bytes on 32 bit, 20 bytes on 64 bit) each time a playlist is loaded. Found by valgrind. Fixes: 2d2637cb4c9ab76fea6bc336b9af88fd00bf5e08 --- diff --git a/playlist.c b/playlist.c index c145b0fd..0a246244 100644 --- a/playlist.c +++ b/playlist.c @@ -176,13 +176,14 @@ int playlist_load(const char *name, struct playlist_instance **result, char **ms *msg = make_message("loaded playlist %s (%u files)\n", name, pi->length); pi->name = para_strdup(name); - if (result) + if (result) { *result = pi; - else { - playlist_unload(NULL); - current_playlist = *pi; + return pi->length; } - return pi->length; + playlist_unload(NULL); + current_playlist = *pi; + free(pi); + return current_playlist.length; close_score_table: if (result) score_close(pi->score_table);