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 <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D8688
This commit is contained in:
Christopher Michael 2019-04-23 09:26:13 -04:00 committed by Marcel Hollerbach
parent e23914fce7
commit 22edf6f4b7
1 changed files with 4 additions and 1 deletions

View File

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