change memory allocation for noti ex item when get item from manager handle
authorSukHyung, Kang <shine.kang@samsung.com>
Wed, 26 Jun 2019 09:16:54 +0000 (18:16 +0900)
committerJusung Son <jusung07.son@samsung.com>
Fri, 12 Jul 2019 01:11:02 +0000 (10:11 +0900)
Change-Id: I6aba07fe61c11dc80d1026ea11ffa366016637d7
Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
notification-ex/stub.cc

index 712e279bb959687c5b395c8fc9f6b5957b8b3726..341c2e87ea46cb9ceb1ae4a4747234a997a1f4da 100644 (file)
@@ -2005,16 +2005,18 @@ extern "C" EXPORT_API int noti_ex_manager_get(noti_ex_manager_h handle,
       *count = 0;
       return NOTI_EX_ERROR_NONE;
     }
-    *items = (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
-    if (*items == nullptr) {
+    noti_ex_item_h* added_item =
+        (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
+    if (added_item == nullptr) {
       LOGE("Fail to create items");
       return NOTI_EX_ERROR_OUT_OF_MEMORY;
     }
 
     int idx = 0;
     for (auto& i : item_list) {
-      *items[idx++] = new Handle(move(i));
+      added_item[idx++] = static_cast<noti_ex_item_h>(new Handle(move(i)));
     }
+    *items = added_item;
     *count = item_list.size();
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());