string_list_free - try to be safer

This commit is contained in:
twinaphex 2019-05-22 05:28:20 +02:00
parent 9c12037c43
commit 15e7078361

View File

@ -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);
}