change memory allocation for noti ex item when get item from manager handle 00/208600/1
authorSukHyung, Kang <shine.kang@samsung.com>
Wed, 26 Jun 2019 09:16:54 +0000 (18:16 +0900)
committerSukHyung, Kang <shine.kang@samsung.com>
Wed, 26 Jun 2019 09:16:54 +0000 (18:16 +0900)
Change-Id: I6aba07fe61c11dc80d1026ea11ffa366016637d7
Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
notification-ex/stub.cc

index 50fa8e30c59806110b8f5694b04f2403f796a63b..7b3f0f7c2223d279f60dcd38b4bfa9becf330b19 100644 (file)
@@ -2045,16 +2045,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());