elementary: fix memory leaks when using elm_prefs 46/153446/1
authorYoungbok Shin <youngb.shin@samsung.com>
Thu, 28 Sep 2017 10:41:56 +0000 (19:41 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Thu, 28 Sep 2017 10:41:56 +0000 (19:41 +0900)
"regex" is heap-allocated and is not handled by regfree().
We must explicitely call free() after a regfree() to remove
the regex_t from memory.

Change-Id: Ib278f4bd49b6246b7d6eaf7f646dd1c36aca4419
Author: Jean Guyomarc'h <jean@guyomarch.bzh>
Date:   Fri Aug 12 16:36:12 2016 +0200

src/modules/prefs/elm_entry.c

index 301842d..21b4f61 100644 (file)
@@ -115,10 +115,18 @@ _entry_del_cb(void *data EINA_UNUSED,
    Ecore_Timer *timer;
 
    regex = evas_object_data_del(obj, "accept_regex");
-   if (regex) regfree(regex);
+   if (regex)
+     {
+        regfree(regex);
+        free(regex);
+     }
 
    regex = evas_object_data_del(obj, "deny_regex");
-   if (regex) regfree(regex);
+   if (regex)
+     {
+        regfree(regex);
+        free(regex);
+     }
 
    timer = evas_object_data_del(obj, "timer");
    if (timer) ecore_timer_del(timer);
@@ -165,6 +173,7 @@ elm_prefs_entry_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED,
           {
              regerror(ret, regex, buf, sizeof(buf));
              regfree(regex);
+             free(regex);
              ERR("bad regular expression (%s) on item's 'accept' tag (%s)."
                  " Because of that, the 'accept' tag will be dropped for the "
                  "item.", spec.s.accept, buf);
@@ -184,6 +193,7 @@ elm_prefs_entry_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED,
           {
              regerror(ret, regex, buf, sizeof(buf));
              regfree(regex);
+             free(regex);
              ERR("bad regular expression (%s) on item's 'deny' tag (%s)."
                  " Because of that, the 'deny' tag will be dropped for the "
                  "item.", spec.s.deny, buf);