From c86204ae093831583a09841d83cbf67d0d4e239c Mon Sep 17 00:00:00 2001 From: Prince Kumar Dubey Date: Tue, 21 Apr 2020 18:11:33 +0530 Subject: [PATCH] [elm_gengrid] To Fix [DEREF_OF_NULL.RET.ALLOC][NO_CAST.INTEGER_DIVISION] Change-Id: I89d5960640338549705fb7cefd79f0f7efec429b Signed-off-by: Prince Kumar Dubey --- src/lib/elementary/elm_gengrid.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/lib/elementary/elm_gengrid.c b/src/lib/elementary/elm_gengrid.c index 591cfa210f..aad2d8d353 100755 --- a/src/lib/elementary/elm_gengrid.c +++ b/src/lib/elementary/elm_gengrid.c @@ -2049,13 +2049,18 @@ _circle_path_pos(Elm_Gengrid_Data *sd, Evas_Coord cx, Evas_Coord cy, Evas_Coord circle_x += item_fx; coords = ELM_NEW(Eina_Position2D); - coords->x = circle_x; - coords->y = circle_y; + if (coords) + { + coords->x = circle_x; + coords->y = circle_y; - tmp = eina_hash_find(sd->circle.coord_cache, key); - if (tmp) - eina_hash_del_by_key(sd->circle.coord_cache, key); - eina_hash_add(sd->circle.coord_cache, key, coords); + tmp = eina_hash_find(sd->circle.coord_cache, key); + if (tmp) + eina_hash_del_by_key(sd->circle.coord_cache, key); + eina_hash_add(sd->circle.coord_cache, key, coords); + } + else + ERR("Failed to allocate memory for Eina_Position2D"); if (fx) *fx = circle_x; if (fy) *fy = circle_y; @@ -2474,7 +2479,7 @@ _item_place(Elm_Gen_Item *it, if (!vi_effect || (vi_effect && !strcmp(vi_effect, "on"))) { - ratio = (float)abs(g_center - i_center) / (float)(oh / 2); + ratio = (float)((float)abs(g_center - i_center) / (float)(oh / 2)); color = GENGRID_ITEM_DIMMED_COLOR + ((255 - GENGRID_ITEM_DIMMED_COLOR) * (1.0 - ratio)); scale_p = (1 - GENGRID_ITEM_INIT_SIZE_RATIO) * (1 - ratio) + GENGRID_ITEM_INIT_SIZE_RATIO; evas_object_color_set(it->item->proxy, color, color, color, color); @@ -3681,6 +3686,11 @@ _store_nearby_items(Elm_Gengrid_Data *sd) rnd->no = abs(sd->reorder.it2->position - sd->reorder.it1->position); rnd->items = malloc(sizeof(Item_Info) * (rnd->no + 1)); + if (!rnd->items) + { + ERR("Failed to allocate memory for Item_Info"); + return; + } rnd->corner_item = NULL; if (sd->horizontal && sd->item_height > 0) -- 2.34.1