From 1adff032afeb1b5719c334c158e5571d0aa53e36 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Fri, 31 Dec 2021 15:26:03 +0900 Subject: [PATCH] Fix defects from static analysis tool Change-Id: I3bac4d47d7f4e1f9f0d26b5cc17198b0f0044fc1 --- src/vc_elm_efl_dump.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/vc_elm_efl_dump.c b/src/vc_elm_efl_dump.c index 067b720..3513494 100644 --- a/src/vc_elm_efl_dump.c +++ b/src/vc_elm_efl_dump.c @@ -326,15 +326,22 @@ _obj_tree_items(Ea_Util_Mgr *util_mgr, Evas_Object *obj, Object_Info *parent) strncpy(object_info->color_class, edje_info->color_class, strlen(edje_info->color_class) + 1); } - ret = edje_object_part_state_get(evas_object_smart_parent_get(obj), edje_info->part_name, &val); - object_info->part_name = calloc(1, strlen(edje_info->part_name) + 1); - object_info->part_state = calloc(1, strlen(ret) + 1); - if (!object_info->part_name || !object_info->part_state) { - VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory"); + object_info->part_name = strdup(edje_info->part_name); + if (!object_info->part_name) { + VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory for part_name"); goto exit; } - strncpy(object_info->part_name, edje_info->part_name, strlen(edje_info->part_name) + 1); - strncpy(object_info->part_state, ret, strlen(ret) + 1); + + ret = edje_object_part_state_get(evas_object_smart_parent_get(obj), edje_info->part_name, &val); + if (ret) { + object_info->part_state = strdup(ret); + if (!object_info->part_state) { + VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory"); + goto exit; + } + } else { + VC_ELM_LOG_INFO("[INFO] Fail to get state, return value is NULL"); + } if (edje_info->image_name) { object_info->image_name = calloc(1, strlen(edje_info->image_name) + 1); @@ -650,15 +657,22 @@ _obj_tree_items_exclude_unfocusable_text(Ea_Util_Mgr *util_mgr, Evas_Object *obj strncpy(object_info->color_class, edje_info->color_class, strlen(edje_info->color_class) + 1); } - ret = edje_object_part_state_get(evas_object_smart_parent_get(obj), edje_info->part_name, &val); - object_info->part_name = calloc(1, strlen(edje_info->part_name) + 1); - object_info->part_state = calloc(1, strlen(ret) + 1); - if (!object_info->part_name || !object_info->part_state) { - VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory"); + object_info->part_name = strdup(edje_info->part_name); + if (!object_info->part_name) { + VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory for part_name"); goto exit; } - strncpy(object_info->part_name, edje_info->part_name, strlen(edje_info->part_name) + 1); - strncpy(object_info->part_state, ret, strlen(ret) + 1); + + ret = edje_object_part_state_get(evas_object_smart_parent_get(obj), edje_info->part_name, &val); + if (ret) { + object_info->part_state = strdup(ret); + if (!object_info->part_state) { + VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory"); + goto exit; + } + } else { + VC_ELM_LOG_INFO("[INFO] Fail to get state, return value is NULL"); + } if (edje_info->image_name) { object_info->image_name = calloc(1, strlen(edje_info->image_name) + 1); -- 2.7.4