Fix memory leak 35/268035/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 15 Dec 2021 05:58:11 +0000 (14:58 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 15 Dec 2021 05:58:11 +0000 (14:58 +0900)
Change-Id: I0d7f57e53c092f757d9c1b30a20772abe08ec626
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/bundle_cpp.cc
src/json-internal.cc

index b8d254b..2ced838 100644 (file)
@@ -118,6 +118,7 @@ Bundle::KeyInfo::KeyInfo(const KeyInfo& k)
     : impl_(new Impl(this)) {
   impl_->handle_ = bundle_keyval_dup(k.impl_->handle_);
   impl_->name_ = k.impl_->name_;
+  impl_->own_ = true;
   if (impl_->handle_ == nullptr)
     throw std::bad_alloc();
 }
index dd8c7df..a6bcdd3 100644 (file)
@@ -118,6 +118,7 @@ std::string Json::ToString() {
   if (json == nullptr)
     THROW(BUNDLE_ERROR_OUT_OF_MEMORY);
 
+  std::unique_ptr<gchar, decltype(g_free)*> json_auto(json, g_free);
   json_ = json;
   return json_;
 }