From 0c39c2ef3fb4768bce32c9645be39429d40b5d6f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 25 Jul 2014 23:33:49 +0200 Subject: [PATCH] Refactor content_history_free_entry --- frontend/menu/menu_common.c | 4 +--- history.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index 34c77a88d3..73e1c803c9 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -242,9 +242,7 @@ void *menu_init(const void *data) if (!menu_ctx) return NULL; - menu = (menu_handle_t*)menu_ctx->init(); - - if (!menu) + if (!(menu = (menu_handle_t*)menu_ctx->init())) return NULL; strlcpy(g_settings.menu.driver, menu_ctx->ident, sizeof(g_settings.menu.driver)); diff --git a/history.c b/history.c index 57b2fc4b63..1c8651f200 100644 --- a/history.c +++ b/history.c @@ -57,9 +57,16 @@ void content_history_get_index(content_history_t *hist, static void content_history_free_entry(struct content_history_entry *entry) { - free(entry->path); - free(entry->core_path); - free(entry->core_name); + if (entry->path) + free(entry->path); + entry->path = NULL; + if (entry->core_path) + free(entry->core_path); + entry->core_path = NULL; + if (entry->core_name) + free(entry->core_name); + entry->core_name = NULL; + memset(entry, 0, sizeof(*entry)); }