From 959fe7a29ed106aec1a9000810b6212be461ab3d Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Wed, 18 Mar 2015 16:10:39 +0100 Subject: [PATCH] Fix parser handlers In current execution flow, there is call of Parse() function for each handler. Handler should be prepared for situation that there is no value it expects. Change-Id: Ib17ed3e4bbb5600397c9bf23cf140d0d064b8d29 --- .../manifest_handlers/app_control_handler.cc | 8 ++++++-- src/widget-manifest-parser/manifest_handlers/category_handler.cc | 8 ++++++-- src/widget-manifest-parser/manifest_handlers/ime_handler.cc | 8 ++++++-- src/widget-manifest-parser/manifest_handlers/metadata_handler.cc | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/widget-manifest-parser/manifest_handlers/app_control_handler.cc b/src/widget-manifest-parser/manifest_handlers/app_control_handler.cc index 13e696a..00b4237 100644 --- a/src/widget-manifest-parser/manifest_handlers/app_control_handler.cc +++ b/src/widget-manifest-parser/manifest_handlers/app_control_handler.cc @@ -68,8 +68,9 @@ bool AppControlHandler::Parse(std::shared_ptr application, std::string* error) { const Manifest* manifest = application->GetManifest(); std::shared_ptr aplist(new AppControlInfoList()); - utils::Value* value; - manifest->Get(keys::kTizenApplicationAppControlsKey, &value); + utils::Value* value = nullptr; + if (!manifest->Get(keys::kTizenApplicationAppControlsKey, &value)) + return true; if (value->GetType() == utils::Value::TYPE_LIST) { // multiple entries @@ -107,6 +108,9 @@ bool AppControlHandler::Validate( static_cast( application->GetManifestData(keys::kTizenApplicationAppControlsKey)); + if (!app_controls) + return true; + for (const auto& item : app_controls->controls) { if (item.src().empty()) { *error = "The src child element of app-control element is obligatory"; diff --git a/src/widget-manifest-parser/manifest_handlers/category_handler.cc b/src/widget-manifest-parser/manifest_handlers/category_handler.cc index 4be306e..80dd8a5 100644 --- a/src/widget-manifest-parser/manifest_handlers/category_handler.cc +++ b/src/widget-manifest-parser/manifest_handlers/category_handler.cc @@ -42,8 +42,9 @@ bool CategoryHandler::Parse(std::shared_ptr application, std::string* error) { const Manifest* manifest = application->GetManifest(); std::shared_ptr aplist(new CategoryInfoList()); - utils::Value* value; - manifest->Get(keys::kTizenCategoryKey, &value); + utils::Value* value = nullptr; + if (!manifest->Get(keys::kTizenCategoryKey, &value)) + return true; if (value->GetType() == utils::Value::TYPE_LIST) { // multiple entries @@ -79,6 +80,9 @@ bool CategoryHandler::Validate( static_cast( application->GetManifestData(keys::kTizenCategoryKey)); + if (!categories_list) + return true; + for (const auto& item : categories_list->categories) { if (item.empty()) { *error = kErrMsgCategoryName; diff --git a/src/widget-manifest-parser/manifest_handlers/ime_handler.cc b/src/widget-manifest-parser/manifest_handlers/ime_handler.cc index 7810fc7..ba15979 100644 --- a/src/widget-manifest-parser/manifest_handlers/ime_handler.cc +++ b/src/widget-manifest-parser/manifest_handlers/ime_handler.cc @@ -125,8 +125,9 @@ bool ImeHandler::Parse(std::shared_ptr application, const Manifest* manifest = application->GetManifest(); assert(manifest); - utils::Value* value; - manifest->Get(keys::kTizenImeKey, &value); + utils::Value* value = nullptr; + if (!manifest->Get(keys::kTizenImeKey, &value) ) + return true; bool result = true; @@ -155,6 +156,9 @@ bool ImeHandler::Validate( static_cast( application->GetManifestData(keys::kTizenImeKey)); + if (!ime_info) + return true; + if (ime_info->uuid().empty()) { *error = kErrMsgValidatingUuidEmpty; return false; diff --git a/src/widget-manifest-parser/manifest_handlers/metadata_handler.cc b/src/widget-manifest-parser/manifest_handlers/metadata_handler.cc index 8106d5f..89f5a58 100644 --- a/src/widget-manifest-parser/manifest_handlers/metadata_handler.cc +++ b/src/widget-manifest-parser/manifest_handlers/metadata_handler.cc @@ -71,6 +71,7 @@ bool MetaDataHandler::Parse(std::shared_ptr application, utils::Value* metadata_value = NULL; if (!manifest->Get(keys::kTizenMetaDataKey, &metadata_value)) { LOG(INFO) << "Failed to get value of tizen metaData"; + return true; } MetaDataPair metadata_item; -- 2.7.4