[Notification] Fix memory leak. 58/271858/3
authorMarcin Bialek <m.bialek@samsung.com>
Wed, 2 Mar 2022 11:58:36 +0000 (12:58 +0100)
committerMarcin Bialek <m.bialek@samsung.com>
Wed, 2 Mar 2022 12:10:39 +0000 (13:10 +0100)
[Verification] Code compiles.

Change-Id: I9e75cfd1d91021eb7a8bb074bcd0505c8002997b

src/notification/common_notification.cc

index cee4084..cd03304 100644 (file)
@@ -745,7 +745,7 @@ PlatformResult CommonNotification::GetEventHandler(notification_h noti_handle,
                                                    notification_event_type_e event_type,
                                                    app_control_h* event_handler) {
   ScopeLogger();
-  app_control_h handler;
+  app_control_h handler = nullptr;
   int ret = notification_get_event_handler(noti_handle, event_type, &handler);
 
   if (NOTIFICATION_ERROR_NONE != ret) {
@@ -755,6 +755,8 @@ PlatformResult CommonNotification::GetEventHandler(notification_h noti_handle,
 
   if (event_handler) {
     *event_handler = handler;
+  } else {
+    app_control_destroy(handler);
   }
 
   return PlatformResult(ErrorCode::NO_ERROR);