From 3b5d15fb2ec2508b09a63f1ad89a3d6bc26e1af3 Mon Sep 17 00:00:00 2001 From: "fabio.olimpieri" Date: Sun, 27 Apr 2014 17:55:10 +0000 Subject: [PATCH] Fixed memory leakage --- src/gui-sdl/menu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui-sdl/menu.c b/src/gui-sdl/menu.c index 475e032..f848a7d 100644 --- a/src/gui-sdl/menu.c +++ b/src/gui-sdl/menu.c @@ -1025,15 +1025,18 @@ static const char *menu_select_file_internal(const char *dir_path, } else opt = menu_select_sized("Select file", file_list, NULL, 0, x, y, x2, y2, NULL, NULL ,16); - if (opt < 0) - return NULL; - sel = strdup(file_list[opt]); + sel = NULL; + + if (opt >= 0) sel = strdup(file_list[opt]); /* Cleanup everything - file_list is NULL-terminated */ for ( i = 0; file_list[i]; i++ ) free((void*)file_list[i]); free(file_list); - + + if (opt < 0) + return NULL; + if (!sel) return NULL;