Fix resouce leak 63/213063/2
authormk5004.lee <mk5004.lee@samsung.com>
Fri, 30 Aug 2019 03:33:06 +0000 (12:33 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Fri, 30 Aug 2019 04:10:17 +0000 (13:10 +0900)
Change-Id: Ie5385a92f0a8f5ce61e3c43648e3069ba686d805
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
notification-ex/app_control_action.cc
notification-ex/dbus_connection_manager.cc
notification-ex/default_action_factory.cc
notification-ex/group_item.cc
unittest/src/test_group_item.cc

index 73b1cd5..9c6f552 100644 (file)
@@ -79,6 +79,7 @@ Bundle AppControlAction::Serialize() const {
   bundle_encode(control_b, &control_raw, &len);
   if (len <= 0) {
     LOGE("bundle encode failed");
+    bundle_free(control_b);
     return {};
   }
 
index 6b81f6a..633fa41 100644 (file)
@@ -82,7 +82,10 @@ std::string DBusConnectionManager::GetBusName(string appid) const {
   if (encoded_str == NULL)
     return "";
 
-  return string(NOTIFICATION_EX_BUS_NAME_PREFIX) + encoded_str;
+  string bus_name = string(NOTIFICATION_EX_BUS_NAME_PREFIX) + encoded_str;
+  g_free(encoded_str);
+
+  return bus_name;
 }
 
 int DBusConnectionManager::Init() {
index fde65ee..fd56f99 100644 (file)
@@ -37,10 +37,13 @@ unique_ptr<AbstractAction> DefaultActionFactory::CreateAction(int type) {
   switch (type) {
     case AbstractAction::NullObject :
       THROW(ERROR_INVALID_PARAMETER);
-    case AbstractAction::AppControl :
+    case AbstractAction::AppControl : {
       app_control_h control;
       app_control_create(&control);
-      return unique_ptr<AbstractAction>(new AppControlAction(control));
+      unique_ptr<AbstractAction> action(new AppControlAction(control));
+      app_control_destroy(control);
+      return action;
+    }
     case AbstractAction::Visibility :
       return unique_ptr<AbstractAction>(new VisibilityAction());
     case AbstractAction::Custom :
index a1bda0e..f03cc88 100644 (file)
@@ -187,6 +187,7 @@ string GroupItem::GetAppLabel() {
     if (ret != APP_ERROR_NONE)
       THROW(ERROR_IO_ERROR);
     impl_->app_label_ = string(name);
+    free(name);
   }
   return impl_->app_label_;
 }
index 6034c37..caa46b0 100644 (file)
@@ -133,7 +133,7 @@ TEST_F(GroupItemTest, FindByIDNullItemReturn) {
 }
 
 int __fake_app_get_name(char** app_name) {
-  *app_name = (char*)"unittest_appname";
+  *app_name = strdup("unittest_appname");
   return 0;
 }