From: Hwankyu Jhun Date: Wed, 28 Oct 2020 00:49:18 +0000 (+0900) Subject: Fix static analysis issues X-Git-Tag: submit/tizen/20201028.051031~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aa4067ec8738109e3963a0ea4bf17bc0fdde23f8;p=platform%2Fcore%2Fapi%2Fnotification.git Fix static analysis issues Issues: - Dereference null return value Change-Id: I23554e80eb1a2492eb2505fadd4b25edd9da3275 Signed-off-by: Hwankyu Jhun --- diff --git a/notification-ex/stub.cc b/notification-ex/stub.cc index 52564fdb..2f3300c2 100644 --- a/notification-ex/stub.cc +++ b/notification-ex/stub.cc @@ -3355,9 +3355,15 @@ extern "C" EXPORT_API int noti_ex_reporter_find_by_channel(noti_ex_reporter_h ha } int size = list_ptr.size(); - int i = 0; + list_item = static_cast(calloc(size, sizeof(Handle*))); + if (list_item == nullptr) { + LOGE("Out of memory"); + *noti_list = nullptr; + *count = 0; + return NOTI_EX_ERROR_OUT_OF_MEMORY; + } - list_item = (Handle**)calloc(size, sizeof(Handle*)); + int i = 0; for (auto& ptr : list_ptr) list_item[i++] = new Handle(std::move(ptr)); @@ -3391,9 +3397,15 @@ extern "C" EXPORT_API int noti_ex_reporter_find_all(noti_ex_reporter_h handle, } int size = list_ptr.size(); - int i = 0; + list_item = static_cast(calloc(size, sizeof(Handle*))); + if (list_item == nullptr) { + LOGE("Out of memory"); + *noti_list = nullptr; + *count = 0; + return NOTI_EX_ERROR_OUT_OF_MEMORY; + } - list_item = (Handle**)calloc(size, sizeof(Handle*)); + int i = 0; for (auto& ptr : list_ptr) list_item[i++] = new Handle(std::move(ptr));