From 25c116e192cfc40c3e42a6f51b57f65f8cd69c7e Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 20 Nov 2017 18:46:07 -0500 Subject: [PATCH 1/3] Fix strdup() memory leak --- menu/widgets/menu_dialog.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/menu/widgets/menu_dialog.c b/menu/widgets/menu_dialog.c index 4e4ecb065b..30f645d824 100644 --- a/menu/widgets/menu_dialog.c +++ b/menu/widgets/menu_dialog.c @@ -263,8 +263,13 @@ void menu_dialog_push(void) info.list = menu_entries_get_menu_stack_ptr(0); info.enum_idx = MENU_ENUM_LABEL_HELP; - info.label = strdup( - msg_hash_to_str(MENU_ENUM_LABEL_HELP)); + + // Set the label string, if it exists. + const char *label = msg_hash_to_str(MENU_ENUM_LABEL_HELP); + if (label) + { + info.label = strdup(label); + } menu_displaylist_ctl(DISPLAYLIST_HELP, &info); } From 9e3d6adf6e7a45006f552d4d9cf0d8be98ac2c4b Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 20 Nov 2017 18:47:27 -0500 Subject: [PATCH 2/3] Fix coding standard --- menu/widgets/menu_dialog.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/menu/widgets/menu_dialog.c b/menu/widgets/menu_dialog.c index 30f645d824..601418347b 100644 --- a/menu/widgets/menu_dialog.c +++ b/menu/widgets/menu_dialog.c @@ -267,9 +267,7 @@ void menu_dialog_push(void) // Set the label string, if it exists. const char *label = msg_hash_to_str(MENU_ENUM_LABEL_HELP); if (label) - { info.label = strdup(label); - } menu_displaylist_ctl(DISPLAYLIST_HELP, &info); } From d36d3e2c89323bd0f6de05e03f545a6365028c8d Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 21 Nov 2017 04:38:38 +0100 Subject: [PATCH 3/3] Update menu_dialog.c --- menu/widgets/menu_dialog.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/menu/widgets/menu_dialog.c b/menu/widgets/menu_dialog.c index 601418347b..4157e31502 100644 --- a/menu/widgets/menu_dialog.c +++ b/menu/widgets/menu_dialog.c @@ -255,6 +255,7 @@ void menu_dialog_push_pending(bool push, enum menu_dialog_type type) void menu_dialog_push(void) { menu_displaylist_info_t info; + const char *label; if (!menu_dialog_is_push_pending()) return; @@ -264,10 +265,10 @@ void menu_dialog_push(void) info.list = menu_entries_get_menu_stack_ptr(0); info.enum_idx = MENU_ENUM_LABEL_HELP; - // Set the label string, if it exists. - const char *label = msg_hash_to_str(MENU_ENUM_LABEL_HELP); + /* Set the label string, if it exists. */ + label = msg_hash_to_str(MENU_ENUM_LABEL_HELP); if (label) - info.label = strdup(label); + info.label = strdup(label); menu_displaylist_ctl(DISPLAYLIST_HELP, &info); }