Fix memory leak 60/144860/2 accepted/tizen_3.0_common accepted/tizen_3.0_ivi accepted/tizen_3.0_mobile accepted/tizen_3.0_tv accepted/tizen/3.0/common/20170821.093636 accepted/tizen/3.0/ivi/20170820.233443 accepted/tizen/3.0/mobile/20170820.233437 accepted/tizen/3.0/tv/20170820.233506 submit/tizen_3.0/20170818.073343
authorSeungha Son <seungha.son@samsung.com>
Fri, 18 Aug 2017 04:47:30 +0000 (13:47 +0900)
committerSeungha Son <seungha.son@samsung.com>
Fri, 18 Aug 2017 07:20:57 +0000 (16:20 +0900)
Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: Ic777cdeb6517bc87e56d1671cd810edf8babbf5c

src/wgt/step/configuration/step_parse.cc

index 17a3ef9..8edeb06 100644 (file)
@@ -31,6 +31,7 @@
 #include <wgt_manifest_handlers/w3c_pc_utils.h>
 
 #include <pkgmgr/pkgmgr_parser.h>
+#include <pkgmgrinfo_basic.h>
 
 #include <string.h>
 
@@ -392,8 +393,11 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
   application->launch_mode = strdup(app_info->launch_mode().c_str());
   for (auto& icon : GListRange<icon_x*>(manifest->icon)) {
     icon_x* app_icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
-    if (!app_icon)
+    if (!app_icon) {
+      LOG(ERROR) << "Out of memory";
+      pkgmgrinfo_basic_free_application(application);
       return false;
+    }
     app_icon->text = strdup(icon->text);
     app_icon->lang = strdup(icon->lang);
     application->icon = g_list_append(application->icon, app_icon);
@@ -442,8 +446,11 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) {
       bf::path icon_path = context_->root_application_path.get()
           / manifest->package / "res" / "wgt" / service_info.icon();
       icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
-      if (!icon)
+      if (!icon) {
+        LOG(ERROR) << "Out of memory";
+        pkgmgrinfo_basic_free_application(application);
         return false;
+      }
       icon->text = strdup(icon_path.c_str());
       icon->lang = strdup(DEFAULT_LOCALE);
       application->icon = g_list_append(application->icon, icon);
@@ -504,8 +511,11 @@ bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) {
 
     if (!app_widget.icon_src.empty()) {
       icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
-      if (!icon)
+      if (!icon) {
+        LOG(ERROR) << "Out of memory";
+        pkgmgrinfo_basic_free_application(application);
         return false;
+      }
       icon->text = strdup(app_widget.icon_src.c_str());
       icon->lang = strdup(DEFAULT_LOCALE);
       application->icon = g_list_append(application->icon, icon);