From 15e7078361c9515b0530c9bb96bf32df7d1b21d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 22 May 2019 05:28:20 +0200 Subject: [PATCH] string_list_free - try to be safer --- libretro-common/lists/string_list.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libretro-common/lists/string_list.c b/libretro-common/lists/string_list.c index a96dd2975a..f9e773194e 100644 --- a/libretro-common/lists/string_list.c +++ b/libretro-common/lists/string_list.c @@ -41,15 +41,18 @@ void string_list_free(struct string_list *list) if (!list) return; - for (i = 0; i < list->size; i++) + if (list->elems) { - if (list->elems[i].data) - free(list->elems[i].data); - list->elems[i].data = NULL; + for (i = 0; i < list->size; i++) + { + if (list->elems[i].data) + free(list->elems[i].data); + list->elems[i].data = NULL; + } + + free(list->elems); } - if (list->elems) - free(list->elems); list->elems = NULL; free(list); }