efl_core_command_line: Fix resource leak
authorChristopher Michael <cp.michael@samsung.com>
Tue, 23 Apr 2019 13:26:13 +0000 (09:26 -0400)
committerYeongjong Lee <yj34.lee@samsung.com>
Wed, 24 Apr 2019 05:24:47 +0000 (14:24 +0900)
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

src/lib/ecore/efl_core_command_line.c

index 1c08403..64de7a9 100644 (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);