From: Doyoun Kang Date: Mon, 17 Jul 2017 11:32:44 +0000 (+0900) Subject: e_place: fix bug detected by static analysis tool X-Git-Tag: accepted/tizen/unified/20170724.155137~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F32%2F139132%2F1;p=platform%2Fupstream%2Fenlightenment.git e_place: fix bug detected by static analysis tool Change-Id: I63361fa5b217abfd9e1cb5a04ab56db0930ed54a --- diff --git a/src/bin/e_place.c b/src/bin/e_place.c index 7bad6aa..77708ef 100644 --- a/src/bin/e_place.c +++ b/src/bin/e_place.c @@ -122,6 +122,8 @@ e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w a_h = 2; a_x = E_NEW(int, 2); a_y = E_NEW(int, 2); + if (!a_x || !a_y) goto error; + a_alloc_w = 2; a_alloc_h = 2; @@ -130,6 +132,7 @@ e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w u_x = calloc(zw + 1, sizeof(char)); u_y = calloc(zh + 1, sizeof(char)); + if (!u_x || !u_y) goto error; a_x[0] = 0; a_x[1] = zw; @@ -179,6 +182,7 @@ e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w { a_alloc_w += 32; E_REALLOC(a_x, int, a_alloc_w); + if (!a_x) goto error; } a_x[a_w - 1] = bx; u_x[bx] = 1; @@ -190,6 +194,7 @@ e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w { a_alloc_w += 32; E_REALLOC(a_x, int, a_alloc_w); + if (!a_x) goto error; } a_x[a_w - 1] = bx + bw; u_x[bx + bw] = 1; @@ -201,6 +206,7 @@ e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w { a_alloc_h += 32; E_REALLOC(a_y, int, a_alloc_h); + if (!a_y) goto error; } a_y[a_h - 1] = by; u_y[by] = 1; @@ -212,6 +218,7 @@ e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w { a_alloc_h += 32; E_REALLOC(a_y, int, a_alloc_h); + if (!a_y) goto error; } a_y[a_h - 1] = by + bh; u_y[by + bh] = 1; @@ -325,6 +332,14 @@ done: *rx += desk->zone->x; *ry += desk->zone->y; return 1; + +error: + E_FREE(a_x); + E_FREE(a_y); + free(u_x); + free(u_y); + + return 0; } E_API int