Fix memory leak 29/210429/5
authormk5004.lee <mk5004.lee@samsung.com>
Fri, 19 Jul 2019 05:21:01 +0000 (14:21 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Tue, 23 Jul 2019 01:31:20 +0000 (10:31 +0900)
Change-Id: I36e7895814d1dfa197428882289dfdf4eaa6acb1
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
notification-ex/app_control_action.cc
notification-ex/stub.cc

index aef6ee4..73b1cd5 100644 (file)
@@ -95,6 +95,7 @@ void AppControlAction::Deserialize(Bundle b) {
   app_control_h app_control = nullptr;
   bundle* b_ = nullptr;
   std::string control_str;
+  int ret;
 
   AbstractAction::Deserialize(b);
 
@@ -106,15 +107,18 @@ void AppControlAction::Deserialize(Bundle b) {
     return;
   }
 
-  app_control_create(&app_control);
-  if (app_control == nullptr) {
+  ret = app_control_create(&app_control);
+  if (ret != APP_CONTROL_ERROR_NONE) {
     LOGE("failed to create app_control");
+    bundle_free(b_);
     return;
   }
 
-  app_control_import_from_bundle(app_control, b_);
-  if (app_control == nullptr) {
+  ret = app_control_import_from_bundle(app_control, b_);
+  bundle_free(b_);
+  if (ret != APP_CONTROL_ERROR_NONE) {
     LOGE("failed to make app_control from bundle");
+    app_control_destroy(app_control);
     return;
   }
 
index c7341a9..ec0ad47 100644 (file)
@@ -1065,12 +1065,6 @@ extern "C" EXPORT_API int noti_ex_padding_create(noti_ex_padding_h *handle,
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
 
-  auto* p = new (std::nothrow) Padding(left, top, right, bottom);
-  if (p == nullptr) {
-    LOGE("Out-of-memory");
-    return NOTI_EX_ERROR_OUT_OF_MEMORY;
-  }
-
   auto* ptr = new (std::nothrow) shared_ptr<Padding>(
       new (std::nothrow) Padding(left, top, right, bottom));
   if (ptr == nullptr || ptr->get() == nullptr) {