Fix memory leak 93/253593/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 16 Feb 2021 02:00:12 +0000 (11:00 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 16 Feb 2021 02:00:26 +0000 (11:00 +0900)
Change-Id: I930fdef4d8f3734c84e61f0c968d74ffa0dbdeb9
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/gen/cpp_gen_base_cb.h

index b8ac596..46f58b2 100644 (file)
@@ -37,15 +37,25 @@ const char CB_BUNDLE[] = R"__cls_bundle(class Bundle final {
   }
 
   Bundle& operator = (Bundle&& b) {
-    raw_ = b.raw_;
-    b.raw_ = nullptr;
+    if (this != &b) {
+      if (raw_)
+        bundle_free(raw_);
+
+      raw_ = b.raw_;
+      b.raw_ = nullptr;
+    }
     return *this;
   }
 
   Bundle(const Bundle& b) : raw_(bundle_dup(b.GetHandle())) {}
 
   Bundle& operator = (const Bundle& b) {
-    raw_ = bundle_dup(b.GetHandle());
+    if (this != &b) {
+      if (raw_)
+        bundle_free(raw_);
+
+      raw_ = bundle_dup(b.GetHandle());
+    }
     return *this;
   }