raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e51699afbc6094fcfc0f62ca2071ae7b8c6e313b

commit e51699afbc6094fcfc0f62ca2071ae7b8c6e313b
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Tue Sep 10 17:29:01 2019 +0100

    efl core cmommand line - implement destructor and thus fix leak
---
 src/lib/ecore/efl_core_command_line.c  | 19 ++++++++++++++++++-
 src/lib/ecore/efl_core_command_line.eo |  5 ++++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/lib/ecore/efl_core_command_line.c 
b/src/lib/ecore/efl_core_command_line.c
index 64de7a9766..f63d0dbbd2 100644
--- a/src/lib/ecore/efl_core_command_line.c
+++ b/src/lib/ecore/efl_core_command_line.c
@@ -203,6 +203,16 @@ _remove_invalid_chars(char *command)
      }
 }
 
+static void
+_clear_command(Efl_Core_Command_Line_Data *pd)
+{
+   if (!pd->command) return;
+   while (eina_array_count(pd->command) > 0)
+     eina_stringshare_del(eina_array_pop(pd->command));
+   eina_array_free(pd->command);
+   pd->command = NULL;
+}
+
 EOLIAN static Eina_Bool
 _efl_core_command_line_command_array_set(Eo *obj EINA_UNUSED, 
Efl_Core_Command_Line_Data *pd, Eina_Array *array)
 {
@@ -210,6 +220,7 @@ _efl_core_command_line_command_array_set(Eo *obj 
EINA_UNUSED, Efl_Core_Command_L
    Eina_Strbuf *command = eina_strbuf_new();
    unsigned int i = 0;
 
+   _clear_command(pd);
    pd->command = eina_array_new(array ? eina_array_count(array) : 0);
    for (i = 0; i < (array ? eina_array_count(array) : 0); ++i)
      {
@@ -219,7 +230,6 @@ _efl_core_command_line_command_array_set(Eo *obj 
EINA_UNUSED, Efl_Core_Command_L
 
         if (!param)
           {
-             free(param);
              while (eina_array_count(pd->command) > 0)
               eina_stringshare_del(eina_array_pop(pd->command));
              eina_array_free(pd->command);
@@ -276,4 +286,11 @@ _efl_core_command_line_command_string_set(Eo *obj 
EINA_UNUSED, Efl_Core_Command_
    return EINA_TRUE;
 }
 
+EOLIAN static void
+_efl_core_command_line_efl_object_destructor(Eo *obj EINA_UNUSED, 
Efl_Core_Command_Line_Data *pd)
+{
+   free(pd->string_command);
+   pd->string_command = NULL;
+   _clear_command(pd);
+}
 #include "efl_core_command_line.eo.c"
diff --git a/src/lib/ecore/efl_core_command_line.eo 
b/src/lib/ecore/efl_core_command_line.eo
index 6a7511d9ad..6eec372954 100644
--- a/src/lib/ecore/efl_core_command_line.eo
+++ b/src/lib/ecore/efl_core_command_line.eo
@@ -1,4 +1,4 @@
-mixin @beta Efl.Core.Command_Line {
+mixin @beta Efl.Core.Command_Line requires Efl.Object {
   [[A mixin that implements standard functions for command lines.
 
     This object parses the command line that gets passed, later the object can 
be accessed via accessor or the string
@@ -79,4 +79,7 @@ mixin @beta Efl.Core.Command_Line {
 
     }
   }
+  implements {
+    Efl.Object.destructor;
+  }
 }

-- 


Reply via email to