elm_index: Fix memory leak issue in realloc failure
authorVivek Ellur <vivek.ellur@samsung.com>
Thu, 22 Oct 2015 19:38:28 +0000 (12:38 -0700)
committerCedric BAIL <cedric@osg.samsung.com>
Thu, 22 Oct 2015 19:40:19 +0000 (12:40 -0700)
Summary:
@Fix

Signed-off-by: Vivek Ellur <vivek.ellur@samsung.com>
Reviewers: cedric

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

src/lib/elm_index.c

index 83194a7..7f3cb39 100644 (file)
@@ -770,14 +770,17 @@ _sel_eval(Evas_Object *obj,
                     {
                        if (label && last)
                          {
-                            label = realloc(label, strlen(label) +
+                            char *temp;
+
+                            temp = realloc(label, strlen(label) +
                                             strlen(last) + 1);
-                            if (!label)
+                            if (!temp)
                               {
+                                 free(label);
                                  free(last);
                                  return;
                               }
-                            strcat(label, last);
+                            label = strcat(temp, last);
                          }
                     }
                   free(last);