From: mk5004.lee Date: Fri, 30 Aug 2019 03:33:06 +0000 (+0900) Subject: Fix resouce leak X-Git-Tag: accepted/tizen/unified/20190904.011504~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F63%2F213063%2F2;p=platform%2Fcore%2Fapi%2Fnotification.git Fix resouce leak Change-Id: Ie5385a92f0a8f5ce61e3c43648e3069ba686d805 Signed-off-by: mk5004.lee --- diff --git a/notification-ex/app_control_action.cc b/notification-ex/app_control_action.cc index 73b1cd5..9c6f552 100644 --- a/notification-ex/app_control_action.cc +++ b/notification-ex/app_control_action.cc @@ -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 {}; } diff --git a/notification-ex/dbus_connection_manager.cc b/notification-ex/dbus_connection_manager.cc index 6b81f6a..633fa41 100644 --- a/notification-ex/dbus_connection_manager.cc +++ b/notification-ex/dbus_connection_manager.cc @@ -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() { diff --git a/notification-ex/default_action_factory.cc b/notification-ex/default_action_factory.cc index fde65ee..fd56f99 100644 --- a/notification-ex/default_action_factory.cc +++ b/notification-ex/default_action_factory.cc @@ -37,10 +37,13 @@ unique_ptr 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(new AppControlAction(control)); + unique_ptr action(new AppControlAction(control)); + app_control_destroy(control); + return action; + } case AbstractAction::Visibility : return unique_ptr(new VisibilityAction()); case AbstractAction::Custom : diff --git a/notification-ex/group_item.cc b/notification-ex/group_item.cc index a1bda0e..f03cc88 100644 --- a/notification-ex/group_item.cc +++ b/notification-ex/group_item.cc @@ -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_; } diff --git a/unittest/src/test_group_item.cc b/unittest/src/test_group_item.cc index 6034c37..caa46b0 100644 --- a/unittest/src/test_group_item.cc +++ b/unittest/src/test_group_item.cc @@ -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; }