Fix the empty json array case 72/241072/1
authorIlho Kim <ilho159.kim@samsung.com>
Fri, 14 Aug 2020 08:39:06 +0000 (17:39 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Fri, 14 Aug 2020 08:39:06 +0000 (17:39 +0900)
The routine to check the empty array must be performed first

Change-Id: I0013fae4c1e4e99ff7ac54881359de2cd68e663b
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/theme_plugin/theme_parser.cc

index 7b66b42..310e039 100644 (file)
@@ -43,6 +43,11 @@ namespace plugin {
 
 bool ThemeParser::ExtractArray(const Json::Value& node,
     std::string parent_key, ThemeInfoBuilder* builder) {
+  if (node.empty()) {
+    LOG(ERROR) << "Empty array is not allowed";
+    return false;
+  }
+
   Json::ValueType element_type = node.begin()->type();
   std::vector<std::string> array_values;
   int ind = 0;
@@ -68,11 +73,6 @@ bool ThemeParser::ExtractArray(const Json::Value& node,
       element_type == Json::ValueType::objectValue)
     return true;
 
-  if (array_values.empty()) {
-    LOG(ERROR) << "Empty array is not allowed";
-    return false;
-  }
-
   builder->PutStringArray(parent_key, array_values);
   return true;
 }