Fix defects from static analysis tool 82/267782/1
authorwn.jang <wn.jang@samsung.com>
Fri, 10 Dec 2021 00:05:57 +0000 (09:05 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Fri, 10 Dec 2021 00:11:50 +0000 (00:11 +0000)
Change-Id: Iaf2fcf0bd0848e3d9bb77ae5d5e84d50591b4f2f

src/vc_elm_efl_dump.c

index 2e7dd121d514f33cb025d948d68fa016ae52e28c..2e027cb4a7130956e3aad6ce42e43459bbbaa616 100644 (file)
@@ -127,7 +127,14 @@ _extract_edje_file_name(Object_Info *object_info, const char *full_path)
        char name[255] = {0, };
        unsigned int i, cnt = 0;
 
-       if (!full_path) return;
+       if (!full_path)  {
+               VC_ELM_LOG_ERR("[ERROR] full_path is NULL");
+               return;
+       }
+       if (!object_info) {
+               VC_ELM_LOG_ERR("[ERROR] object_info is NULL");
+               return;
+       }
 
        for (i = 0; i < strlen(full_path); i++) {
                if (full_path[i] == '/') {
@@ -138,6 +145,10 @@ _extract_edje_file_name(Object_Info *object_info, const char *full_path)
        }
        name[cnt] = '\0';
        object_info->edje_file = calloc(1, strlen(name) + 1);
+       if (!object_info->edje_file) {
+               VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+               return;
+       }
        strncpy(object_info->edje_file, name, strlen(name) + 1);
 }
 
@@ -240,9 +251,17 @@ _obj_tree_items(Ea_Util_Mgr *util_mgr, Evas_Object *obj, Object_Info *parent)
        // evas object type check
        if (evas_object_is_swallow_rect(obj)) {
                object_info->type = calloc(1, strlen("swallow") + 1);
+               if (!object_info->type) {
+                       VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                       return;
+               }
                strncpy(object_info->type, "swallow", strlen("swallow") + 1);
        } else if (evas_object_type_match(obj, "rectangle")) {
                object_info->type = calloc(1, strlen("rect") + 1);
+               if (!object_info->type) {
+                       VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                       return;
+               }
                strncpy(object_info->type, "rect", strlen("rect") + 1);
                evas_object_color_get(obj, &r, &g, &b, &a);
                object_info->rgb_info.r = r;
@@ -251,6 +270,10 @@ _obj_tree_items(Ea_Util_Mgr *util_mgr, Evas_Object *obj, Object_Info *parent)
                object_info->rgb_info.a = a;
        } else {
                object_info->type = calloc(1, strlen(EVAS_OBJECT_TYPE_GET(obj)) + 1);
+               if (!object_info->type) {
+                       VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                       return;
+               }
                strncpy(object_info->type, EVAS_OBJECT_TYPE_GET(obj), strlen(EVAS_OBJECT_TYPE_GET(obj)) + 1);
        }
 
@@ -278,6 +301,10 @@ _obj_tree_items(Ea_Util_Mgr *util_mgr, Evas_Object *obj, Object_Info *parent)
                edje_object_file_get(obj, &file, &group);
                if (group) {
                        object_info->group = calloc(1, strlen(group) + 1);
+                       if (!object_info->group) {
+                               VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                               return;
+                       }
                        strncpy(object_info->group, group, strlen(group) + 1);
                }
 
@@ -292,17 +319,29 @@ _obj_tree_items(Ea_Util_Mgr *util_mgr, Evas_Object *obj, Object_Info *parent)
                        if (edje_info->obj == obj) {
                                if (edje_info->color_class) {
                                        object_info->color_class = calloc(1, strlen(edje_info->color_class) + 1);
+                                       if (!object_info->color_class) {
+                                               VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                                               return;
+                                       }
                                        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");
+                                       return;
+                               }
                                strncpy(object_info->part_name, edje_info->part_name, strlen(edje_info->part_name) + 1);
                                strncpy(object_info->part_state, ret, strlen(ret) + 1);
 
                                if (edje_info->image_name) {
                                        object_info->image_name = calloc(1, strlen(edje_info->image_name) + 1);
+                                       if (!object_info->image_name) {
+                                               VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                                               return;
+                                       }
                                        strncpy(object_info->image_name, edje_info->image_name, strlen(edje_info->image_name) + 1);
                                }
                                break;
@@ -325,6 +364,10 @@ _obj_tree_items(Ea_Util_Mgr *util_mgr, Evas_Object *obj, Object_Info *parent)
        }
        if (text && strlen(text) > 0) {
                object_info->text = calloc(1, strlen(text) + 1);
+               if (!object_info->text) {
+                       VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                       return;
+               }
                strncpy(object_info->text, text, strlen(text) + 1);
        }
 
@@ -520,9 +563,17 @@ _obj_tree_items_exclude_unfocusable_text(Ea_Util_Mgr *util_mgr, Evas_Object *obj
        // evas object type check
        if (evas_object_is_swallow_rect(obj)) {
                object_info->type = calloc(1, strlen("swallow") + 1);
+               if (!object_info->type) {
+                       VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                       return;
+               }
                strncpy(object_info->type, "swallow", strlen("swallow") + 1);
        } else if (evas_object_type_match(obj, "rectangle")) {
                object_info->type = calloc(1, strlen("rect") + 1);
+               if (!object_info->type) {
+                       VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                       return;
+               }
                strncpy(object_info->type, "rect", strlen("rect") + 1);
                evas_object_color_get(obj, &r, &g, &b, &a);
                object_info->rgb_info.r = r;
@@ -531,6 +582,10 @@ _obj_tree_items_exclude_unfocusable_text(Ea_Util_Mgr *util_mgr, Evas_Object *obj
                object_info->rgb_info.a = a;
        } else {
                object_info->type = calloc(1, strlen(EVAS_OBJECT_TYPE_GET(obj)) + 1);
+               if (!object_info->type) {
+                       VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                       return;
+               }
                strncpy(object_info->type, EVAS_OBJECT_TYPE_GET(obj), strlen(EVAS_OBJECT_TYPE_GET(obj)) + 1);
        }
 
@@ -558,6 +613,10 @@ _obj_tree_items_exclude_unfocusable_text(Ea_Util_Mgr *util_mgr, Evas_Object *obj
                edje_object_file_get(obj, &file, &group);
                if (group) {
                        object_info->group = calloc(1, strlen(group) + 1);
+                       if (!object_info->group) {
+                               VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                               return;
+                       }
                        strncpy(object_info->group, group, strlen(group) + 1);
                }
 
@@ -572,17 +631,29 @@ _obj_tree_items_exclude_unfocusable_text(Ea_Util_Mgr *util_mgr, Evas_Object *obj
                        if (edje_info->obj == obj) {
                                if (edje_info->color_class) {
                                        object_info->color_class = calloc(1, strlen(edje_info->color_class) + 1);
+                                       if (!object_info->color_class) {
+                                               VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                                               return;
+                                       }
                                        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");
+                                       return;
+                               }
                                strncpy(object_info->part_name, edje_info->part_name, strlen(edje_info->part_name) + 1);
                                strncpy(object_info->part_state, ret, strlen(ret) + 1);
 
                                if (edje_info->image_name) {
                                        object_info->image_name = calloc(1, strlen(edje_info->image_name) + 1);
+                                       if (!object_info->image_name) {
+                                               VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                                               return;
+                                       }
                                        strncpy(object_info->image_name, edje_info->image_name, strlen(edje_info->image_name) + 1);
                                }
                                break;
@@ -651,6 +722,10 @@ _obj_tree_items_exclude_unfocusable_text(Ea_Util_Mgr *util_mgr, Evas_Object *obj
        }
        if (text && strlen(text) > 0) {
                object_info->text = calloc(1, strlen(text) + 1);
+               if (!object_info->text) {
+                       VC_ELM_LOG_ERR("[ERROR] Fail to allocate memory");
+                       return;
+               }
                strncpy(object_info->text, text, strlen(text) + 1);
        }