e_comp: fix condition check for realloc 37/139337/2
authorSangjin Lee <lsj119@samsung.com>
Tue, 18 Jul 2017 11:06:57 +0000 (20:06 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Wed, 19 Jul 2017 11:31:57 +0000 (11:31 +0000)
It should be checked the return value for an error condition.
If it fails, realloc returns NULL. so if you use same value for return and param of realloc,
it is memory leak.

Change-Id: Iabdd913949fa30005cb56be6d824c2b7abb4ed2f

src/bin/e_comp.c

index b76c104..b301879 100644 (file)
@@ -1263,7 +1263,7 @@ _e_comp_shapes_update_job(void *d EINA_UNUSED)
    Evas_Object *o = NULL;
    Eina_Rectangle *tr;
    Eina_Iterator *ti;
-   Eina_Rectangle *exr;
+   Eina_Rectangle *exr, *exr_new;
    unsigned int i, tile_count;
 #ifdef SHAPE_DEBUG
    Eina_Rectangle *r;
@@ -1318,8 +1318,9 @@ _e_comp_shapes_update_job(void *d EINA_UNUSED)
         exr[i++] = *(Eina_Rectangle*)((char*)tr);
         if (i == tile_count - 1)
           {
-             exr = realloc(exr, sizeof(Eina_Rectangle) * (tile_count *= 2));
-             EINA_SAFETY_ON_NULL_GOTO(exr, exr_fail);
+             exr_new = realloc(exr, sizeof(Eina_Rectangle) * (tile_count *= 2));
+             EINA_SAFETY_ON_NULL_GOTO(exr_new, exr_fail);
+             exr = exr_new;
           }
 #ifdef SHAPE_DEBUG
         Eina_List *l;