From f893ef54d39aab6ab11ee038a8028612d8bdd313 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Tue, 23 Apr 2019 09:26:13 -0400 Subject: [PATCH] efl_core_command_line: Fix resource leak Coverity reports that we leak the return from _escape(command) here, so since we have to free the return from _escape, place it in it's own variable that we can call free() on after we are done with it. Fixes CID1399105 @fix Reviewed-by: Marcel Hollerbach Differential Revision: https://phab.enlightenment.org/D8688 --- src/lib/ecore/efl_core_command_line.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore/efl_core_command_line.c b/src/lib/ecore/efl_core_command_line.c index 1c084030f1..64de7a9766 100644 --- a/src/lib/ecore/efl_core_command_line.c +++ b/src/lib/ecore/efl_core_command_line.c @@ -215,6 +215,7 @@ _efl_core_command_line_command_array_set(Eo *obj EINA_UNUSED, Efl_Core_Command_L { char *content = eina_array_data_get(array, i); char *param = calloc(1, strlen(content) + 1); + char *esc; if (!param) { @@ -236,7 +237,9 @@ _efl_core_command_line_command_array_set(Eo *obj EINA_UNUSED, Efl_Core_Command_L //build the command if (i != 0) eina_strbuf_append(command, " "); - eina_strbuf_append(command, _escape(content)); + esc = _escape(content); + eina_strbuf_append(command, esc); + free(esc); //convert string to stringshare strcpy(param, content); _remove_invalid_chars(param);