Fix static analysis issues 54/313654/1
authorHwankyu Jhun <h.jhun@samsung.com>
Sun, 30 Jun 2024 23:49:20 +0000 (08:49 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Sun, 30 Jun 2024 23:49:20 +0000 (08:49 +0900)
Checker:
 - MEMORY_LEAK

Change-Id: I6c3bf1f4947b780caab325f08cfcb4e28699ab60
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
component_based/app_control/component_based_app_control.cc

index 470e05231b386254982b7980163f08ceb186bcc4..4b6a186c1f97c623c2101d041aea5295f9510890 100644 (file)
@@ -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;
 }