Fix static analysis issue 71/197971/2
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 17 Jan 2019 10:21:33 +0000 (19:21 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 17 Jan 2019 11:01:06 +0000 (20:01 +0900)
Change-Id: I99998235039fac7f78ce3a5f69be9ef7d61dd375
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/lib/tpk_archive_info.cc
src/tpk/step/configuration/step_adjust_install_location.cc
src/tpk/step/pkgmgr/step_manifest_adjustment.cc

index 890a038..7680a55 100644 (file)
@@ -307,6 +307,11 @@ bool TpkArchiveInfo::GetArchiveInfo(const char* file_path,
   char* locale = vconf_get_str(kVconfLanguageKey);
   if (!locale)
     locale = strdup("");
+  if (!locale) {
+    LOG(ERROR) << "Out of memory";
+    return false;
+  }
+
   LOG(INFO) << "Current locale: " << locale;
   if (!GetLabelInfo(parser, locale, info))
     LOG(WARNING) << "Failed to get label info";
index 5739dfd..a67cf2d 100644 (file)
@@ -27,6 +27,11 @@ ci::Step::Status StepAdjustInstallLocation::process() {
     // This may be allocated by step parse
     free(const_cast<char*>(manifest->installlocation));
     manifest->installlocation = strdup(kAutoLocation);
+    if (!manifest->installlocation) {
+      LOG(ERROR) << "Out of memory";
+      return Status::ERROR;
+    }
+
   }
   return Status::OK;
 }
index 7f30472..b294429 100644 (file)
@@ -141,10 +141,24 @@ common_installer::Step::Status StepManifestAdjustment::process() {
         if (app->autorestart)
           free(app->autorestart);
         app->autorestart = strdup("false");
+        if (!app->autorestart) {
+          LOG(ERROR) << "Out of memory";
+          xmlXPathFreeObject(xpath_obj);
+          xmlXPathFreeContext(xpath_ctx);
+          xmlFreeDoc(doc);
+          return Step::Status::ERROR;
+        }
 
         if (app->onboot)
           free(app->onboot);
         app->onboot = strdup("false");
+        if (!app->onboot) {
+          LOG(ERROR) << "Out of memory";
+          xmlXPathFreeObject(xpath_obj);
+          xmlXPathFreeContext(xpath_ctx);
+          xmlFreeDoc(doc);
+          return Step::Status::ERROR;
+        }
       }
       xmlXPathFreeContext(xpath_ctx);
     }