Fix parser handlers 22/37122/2 accepted/tizen_3.0.2015.q1_common tizen_3.0.2015.q1_common accepted/tizen/3.0.2015.q1/common/20150320.110440 accepted/tizen/common/20150319.155422 accepted/tizen/mobile/20150326.005122 accepted/tizen/tv/20150324.014504 accepted/tizen/wearable/20150323.005717 submit/tizen_3.0.2015.q1_common/20150320.103259 submit/tizen_common/20150319.154254 submit/tizen_mobile/20150325.000000 submit/tizen_tv/20150320.000001 submit/tizen_wearable/20150320.000000
authorTomasz Iwanek <t.iwanek@samsung.com>
Wed, 18 Mar 2015 15:10:39 +0000 (16:10 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Thu, 19 Mar 2015 15:12:06 +0000 (08:12 -0700)
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

src/widget-manifest-parser/manifest_handlers/app_control_handler.cc
src/widget-manifest-parser/manifest_handlers/category_handler.cc
src/widget-manifest-parser/manifest_handlers/ime_handler.cc
src/widget-manifest-parser/manifest_handlers/metadata_handler.cc

index 13e696a..00b4237 100644 (file)
@@ -68,8 +68,9 @@ bool AppControlHandler::Parse(std::shared_ptr<ApplicationData> application,
     std::string* error) {
   const Manifest* manifest = application->GetManifest();
   std::shared_ptr<AppControlInfoList> 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<const AppControlInfoList*>(
           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";
index 4be306e..80dd8a5 100644 (file)
@@ -42,8 +42,9 @@ bool CategoryHandler::Parse(std::shared_ptr<ApplicationData> application,
     std::string* error) {
   const Manifest* manifest = application->GetManifest();
   std::shared_ptr<CategoryInfoList> 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<const CategoryInfoList*>(
           application->GetManifestData(keys::kTizenCategoryKey));
 
+  if (!categories_list)
+    return true;
+
   for (const auto& item : categories_list->categories) {
     if (item.empty()) {
       *error = kErrMsgCategoryName;
index 7810fc7..ba15979 100644 (file)
@@ -125,8 +125,9 @@ bool ImeHandler::Parse(std::shared_ptr<ApplicationData> 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<const ImeInfo*>(
           application->GetManifestData(keys::kTizenImeKey));
 
+  if (!ime_info)
+    return true;
+
   if (ime_info->uuid().empty()) {
     *error = kErrMsgValidatingUuidEmpty;
     return false;
index 8106d5f..89f5a58 100644 (file)
@@ -71,6 +71,7 @@ bool MetaDataHandler::Parse(std::shared_ptr<ApplicationData> 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;