Fix memory leak 69/205969/2
authorhyunho <hhstark.kang@samsung.com>
Mon, 13 May 2019 02:04:30 +0000 (11:04 +0900)
committerhyunho <hhstark.kang@samsung.com>
Mon, 13 May 2019 02:41:05 +0000 (11:41 +0900)
Change-Id: I1cfbb1505ba701e7b6faeeb007515f4cf8e75a86
Signed-off-by: hyunho <hhstark.kang@samsung.com>
watchface-complication-provider/complication-provider.cc

index 87f5252..417386a 100644 (file)
@@ -221,8 +221,6 @@ void ComplicationProvider::Impl::OnSignal(GDBusConnection* connection,
   int complication_id;
   char* context_raw = NULL;
   int type;
-  Bundle* context_data;
-  Bundle* shared_data;
   bool ret;
   bool is_valid;
   char num_str[32] = {0, };
@@ -277,14 +275,20 @@ void ComplicationProvider::Impl::OnSignal(GDBusConnection* connection,
 
     LOGI("get : %s, %d, %d", sender_app_id, complication_id, type);
 
+    Bundle* context_data = nullptr;
+    Bundle* shared_data = nullptr;
     try {
       context_data = new Bundle(std::string(context_raw));
       shared_data = new Bundle();
     } catch (const std::bad_alloc &ba) {
       LOGE("Bundle::Exception bad_alloc");
+      if (context_data != nullptr)
+        delete context_data;
       return;
     } catch (Exception &ex) {
       LOGE("%s %d", ex.what(), ex.GetErrorCode());
+      if (context_data != nullptr)
+        delete context_data;
       return;
     }