elementary/fileselector
authorhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 6 Dec 2011 08:18:14 +0000 (08:18 +0000)
committerhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 6 Dec 2011 08:18:14 +0000 (08:18 +0000)
Hi,

On behalf of Rajeev Ranjan, I am submitting the elc_fileselector patch.

Change Log:
Fix for the memory leak in function elm_fileselector_selected_get. Memory allocated by ecore_file_dir_get() internally using strdup was not freed.
Introduced a char *dir variable to store the memory returned by ecore_file_dir_get() function and releasing the memory before returning to caller.

Please review it.
I'd appreciate any comments on this.

Thank you,
Prince

Signed-Off-By: Rajeev Ranjan (rajeev.r@samsung.com)
Signed-Off-By: Prince Kumar Dubey (prince.dubey@samsung.com)
Signed-Off-By: ChunEon Park (hermet@hermetpe.kr)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@65950 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elc_fileselector.c

index 513af28..cc61117 100644 (file)
@@ -1138,12 +1138,14 @@ elm_fileselector_selected_get(const Evas_Object *obj)
      {
         const char *name;
         char buf[PATH_MAX];
+        char *dir;
 
+        dir = wd->only_folder ? ecore_file_dir_get(wd->path) : strdup(wd->path);
         name = elm_entry_entry_get(wd->filename_entry);
         snprintf(buf, sizeof(buf), "%s/%s",
-                 wd->only_folder ? ecore_file_dir_get(wd->path) : wd->path,
-                 name);
+                 dir, name);
         eina_stringshare_replace(&wd->selection, buf);
+        if (dir) free(dir);
         return wd->selection;
      }