Fix static analysis issues 31/247531/1
authorChanggyu Choi <changyu.choi@samsung.com>
Thu, 12 Nov 2020 02:03:13 +0000 (11:03 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Thu, 12 Nov 2020 02:10:15 +0000 (11:10 +0900)
Change-Id: I02163c95b0bda034b73b59c3ee6bf8a5f667b132
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
notification-ex/stub.cc
notification/src/notification_shared_file.c

index 7d523e6..f79ebdb 100644 (file)
@@ -1347,6 +1347,8 @@ extern "C" EXPORT_API int noti_ex_padding_create(noti_ex_padding_h *handle,
       new (std::nothrow) Padding(left, top, right, bottom));
   if (ptr == nullptr || ptr->get() == nullptr) {
     LOGE("Out-of-memory");
+    if (ptr != nullptr)
+      delete(ptr);
     return NOTI_EX_ERROR_OUT_OF_MEMORY;
   }
 
@@ -1430,6 +1432,8 @@ extern "C" EXPORT_API int noti_ex_geometry_create(noti_ex_geometry_h *handle,
       new (std::nothrow) Geometry(x, y, w, h));
   if (ptr == nullptr || ptr->get() == nullptr) {
     LOGE("Out-of-memory");
+    if (ptr != nullptr)
+      delete ptr;
     return NOTI_EX_ERROR_OUT_OF_MEMORY;
   }
 
@@ -1522,6 +1526,8 @@ extern "C" EXPORT_API int noti_ex_style_create(noti_ex_style_h *handle,
       new (std::nothrow) Style(col, padd, geo));
   if (ptr == nullptr || ptr->get() == nullptr) {
     LOGE("Out-of-memory");
+    if (ptr != nullptr)
+      delete ptr;
     return NOTI_EX_ERROR_OUT_OF_MEMORY;
   }
 
@@ -1651,6 +1657,8 @@ extern "C" EXPORT_API int noti_ex_style_get_geometry(noti_ex_style_h handle,
       new (std::nothrow) Geometry(*((*p)->GetGeometry())));
   if (geo == nullptr || geo->get() == nullptr) {
     LOGE("Out-of-memory");
+    if (geo != nullptr)
+      delete geo;
     return NOTI_EX_ERROR_OUT_OF_MEMORY;
   }
 
@@ -2143,6 +2151,8 @@ extern "C" EXPORT_API int noti_ex_item_get_style(noti_ex_item_h handle,
   auto* ptr = new (std::nothrow) shared_ptr<Style>(new (std::nothrow) Style(*s));
   if (ptr == nullptr || ptr->get() == nullptr) {
     LOGE("Out of memory");
+    if (ptr != nullptr)
+      delete ptr;
     return NOTI_EX_ERROR_OUT_OF_MEMORY;
   }
 
index 9a585f2..c86cdeb 100644 (file)
@@ -1238,9 +1238,11 @@ out:
        tmp_list = g_list_find_custom(__uid_list, GINT_TO_POINTER(req_data->uid),
                        __comp_uid_info_list);
 
-       uid_info = tmp_list->data;
-       uid_info->sharing_req_list = g_list_remove(uid_info->sharing_req_list,
-                       req_data);
+       if (tmp_list != NULL) {
+               uid_info = tmp_list->data;
+               uid_info->sharing_req_list = g_list_remove(
+                               uid_info->sharing_req_list, req_data);
+       }
        __free_req_info(req_data);
 
        return FALSE;