From bbe31739060ea099a72c021bb16acb604353e1b9 Mon Sep 17 00:00:00 2001 From: Stafford Horne Date: Thu, 19 Nov 2015 20:44:45 -0500 Subject: [PATCH] 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 2e1648f46..ffae12ff4 100644 --- a/src/bin/e_module.c +++ b/src/bin/e_module.c @@ -152,6 +152,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; @@ -181,7 +182,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)) { @@ -192,10 +193,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; }