Fix defects from static analysis tool 50/268750/2
authorwn.jang <wn.jang@samsung.com>
Fri, 31 Dec 2021 06:26:03 +0000 (15:26 +0900)
committerwn.jang <wn.jang@samsung.com>
Fri, 31 Dec 2021 06:30:38 +0000 (15:30 +0900)
Change-Id: I3bac4d47d7f4e1f9f0d26b5cc17198b0f0044fc1

src/vc_elm_efl_dump.c

index 067b720..3513494 100644 (file)
@@ -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);