From 0e27e8fa36a92aefbbd0f30b6199d355fa694799 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 1 Jul 2024 08:49:20 +0900 Subject: [PATCH] Fix static analysis issues Checker: - MEMORY_LEAK Change-Id: I6c3bf1f4947b780caab325f08cfcb4e28699ab60 Signed-off-by: Hwankyu Jhun --- .../app_control/component_based_app_control.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/component_based/app_control/component_based_app_control.cc b/component_based/app_control/component_based_app_control.cc index 470e052..4b6a186 100644 --- a/component_based/app_control/component_based_app_control.cc +++ b/component_based/app_control/component_based_app_control.cc @@ -154,6 +154,11 @@ AppControl::AppControl(const AppControl& control) { AppControl& AppControl::operator=(const AppControl& control) { if (this != &control) { + if (impl_->handle_) { + app_control_destroy(impl_->handle_); + impl_->handle_ = nullptr; + } + app_control_h handle = nullptr; if (app_control_clone(&handle, control.impl_->handle_) != APP_CONTROL_ERROR_NONE) { @@ -171,8 +176,12 @@ AppControl::AppControl(AppControl&& control) { AppControl& AppControl::operator=(AppControl&& control) { if (this != &control) { + if (impl_->handle_) + app_control_destroy(impl_->handle_); + impl_->handle_ = control.impl_->handle_; control.impl_->handle_ = nullptr; + app_control_create(&control.impl_->handle_); } return *this; } -- 2.34.1