edje: fix memory leak on realloc.
authorSrivardhan Hebbar <sri.hebbar@samsung.com>
Mon, 19 Oct 2015 18:08:13 +0000 (11:08 -0700)
committerCedric BAIL <cedric@osg.samsung.com>
Mon, 19 Oct 2015 18:10:15 +0000 (11:10 -0700)
Summary: Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>

Reviewers: cedric

Differential Revision: https://phab.enlightenment.org/D3186

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/edje/edje_util.c

index 9a1b446..aa77208 100644 (file)
@@ -5639,7 +5639,7 @@ _edje_program_remove(Edje_Part_Collection *edc, Edje_Program *p)
 EAPI void
 _edje_program_insert(Edje_Part_Collection *edc, Edje_Program *p)
 {
-   Edje_Program ***array;
+   Edje_Program ***array, **temp;
    unsigned int *count;
 
    if (!p->signal && !p->source)
@@ -5671,8 +5671,16 @@ _edje_program_insert(Edje_Part_Collection *edc, Edje_Program *p)
         count = &edc->programs.fnmatch_count;
      }
 
+   temp = *array;
    *array = realloc(*array, sizeof (Edje_Program *) * (*count + 1));
-   (*array)[(*count)++] = p;
+   if (*array)
+     {
+        (*array)[(*count)++] = p;
+     }
+   else
+     {
+        *array = temp;
+     }
 }
 
 const char *