(menu_list.c) menu_list_new - prevent some possible leaks
This commit is contained in:
parent
c9519b90fd
commit
f9ab351bf9
|
@ -176,6 +176,10 @@ void menu_list_free(menu_list_t *menu_list)
|
||||||
|
|
||||||
menu_list_free_list(menu_list->menu_stack);
|
menu_list_free_list(menu_list->menu_stack);
|
||||||
menu_list_free_list(menu_list->selection_buf);
|
menu_list_free_list(menu_list->selection_buf);
|
||||||
|
|
||||||
|
menu_list->menu_stack = NULL;
|
||||||
|
menu_list->selection_buf = NULL;
|
||||||
|
|
||||||
free(menu_list);
|
free(menu_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +195,12 @@ menu_list_t *menu_list_new(void)
|
||||||
|
|
||||||
if (!list->menu_stack || !list->selection_buf)
|
if (!list->menu_stack || !list->selection_buf)
|
||||||
{
|
{
|
||||||
|
if (list->menu_stack)
|
||||||
|
free(list->menu_stack);
|
||||||
|
list->menu_stack = NULL;
|
||||||
|
if (list->selection_buf)
|
||||||
|
free(list->selection_buf);
|
||||||
|
list->selection_buf = NULL;
|
||||||
free(list);
|
free(list);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue