From: Junghyun Yeon Date: Thu, 17 Jan 2019 10:21:33 +0000 (+0900) Subject: Fix static analysis issue X-Git-Tag: submit/tizen/20190215.085133~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F197971%2F2;p=platform%2Fcore%2Fappfw%2Ftpk-backend.git Fix static analysis issue Change-Id: I99998235039fac7f78ce3a5f69be9ef7d61dd375 Signed-off-by: Junghyun Yeon --- diff --git a/src/lib/tpk_archive_info.cc b/src/lib/tpk_archive_info.cc index 890a038..7680a55 100644 --- a/src/lib/tpk_archive_info.cc +++ b/src/lib/tpk_archive_info.cc @@ -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"; diff --git a/src/tpk/step/configuration/step_adjust_install_location.cc b/src/tpk/step/configuration/step_adjust_install_location.cc index 5739dfd..a67cf2d 100644 --- a/src/tpk/step/configuration/step_adjust_install_location.cc +++ b/src/tpk/step/configuration/step_adjust_install_location.cc @@ -27,6 +27,11 @@ ci::Step::Status StepAdjustInstallLocation::process() { // This may be allocated by step parse free(const_cast(manifest->installlocation)); manifest->installlocation = strdup(kAutoLocation); + if (!manifest->installlocation) { + LOG(ERROR) << "Out of memory"; + return Status::ERROR; + } + } return Status::OK; } diff --git a/src/tpk/step/pkgmgr/step_manifest_adjustment.cc b/src/tpk/step/pkgmgr/step_manifest_adjustment.cc index 7f30472..b294429 100644 --- a/src/tpk/step/pkgmgr/step_manifest_adjustment.cc +++ b/src/tpk/step/pkgmgr/step_manifest_adjustment.cc @@ -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); }