discomfitor pushed a commit to branch enlightenment-0.19.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=38411a86246b4d95a93bec549fb516f39b2c6a8d

commit 38411a86246b4d95a93bec549fb516f39b2c6a8d
Author: Stafford Horne <sho...@gmail.com>
Date:   Thu Nov 19 20:44:45 2015 -0500

    e/core: Fix minor mem leak when reading module paths
    
    Summary:
    Found this with a quick valgrind session.  For paths that are not 
directories, if we fail the `ecore_file_is_dir` condition memory will not be 
freed.
    
    The change is to use the default e_path freeing function.
    
    Test Plan:
    Run enlightenment in valgrind.  It should no longer show a mem leak like 
below.
    
    ```
    ==6912== 8 bytes in 1 blocks are definitely lost in loss record 186 of 5,940
    ==6912==    at 0x4C28C50: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==6912==    by 0x4D8574: e_path_dir_list_get (e_path.c:326)
    ==6912==    by 0x4D1BA4: e_module_init.part.0 (e_module.c:183)
    ==6912==    by 0x4D1DA8: e_module_init (e_module.c:153)
    ==6912==    by 0x4371ED: main (e_main.c:868)
    ```
    
    Reviewers: zmike
    
    Subscribers: cedric, seoz
    
    Differential Revision: https://phab.enlightenment.org/D3356
---
 src/bin/e_module.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/bin/e_module.c b/src/bin/e_module.c
index 4f110ad..56aa721 100644
--- a/src/bin/e_module.c
+++ b/src/bin/e_module.c
@@ -136,6 +136,7 @@ EINTERN int
 e_module_init(void)
 {
    Eina_List *module_paths;
+   Eina_List *next_path;
    E_Path_Dir *epd;
    Eio_Monitor *mon;
    Eio_File *ls;
@@ -165,7 +166,7 @@ e_module_init(void)
           }
      }
    module_paths = e_path_dir_list_get(path_modules);
-   EINA_LIST_FREE(module_paths, epd)
+   EINA_LIST_FOREACH(module_paths, next_path, epd)
      {
         if (ecore_file_is_dir(epd->dir))
           {
@@ -176,10 +177,9 @@ e_module_init(void)
              ls = eio_file_direct_ls(epd->dir, _module_filter_cb, 
_module_main_cb, _module_done_cb, _module_error_cb, data);
              _e_module_path_monitors = 
eina_list_append(_e_module_path_monitors, mon);
              _e_module_path_lists = eina_list_append(_e_module_path_lists, ls);
-             eina_stringshare_del(epd->dir);
-             free(epd);
           }
      }
+   e_path_dir_list_free(module_paths);
 
    return 1;
 }

-- 


Reply via email to