diff options
author | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2020-09-08 16:42:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-08 09:42:12 -0400 |
commit | a36ea82740e648debf1b0367c24fed85d6ef2d80 (patch) | |
tree | 6914f9914737da58eda2e87190f394b72a404b42 | |
parent | 10f19d1b142f92d9c617216795c5c0df664607bc (diff) | |
download | sdl_core-a36ea82740e648debf1b0367c24fed85d6ef2d80.tar.gz |
Validate the data before dereferencing it (#3493)
-rw-r--r-- | src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc index 768502832d..61524546a8 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc @@ -296,6 +296,11 @@ smart_objects::SmartObject RCHelpers::MergeModuleData( smart_objects::SmartObject result = data1; + if (data2.empty()) { + SDL_LOG_ERROR("Data received from module is empty"); + return result; + } + for (auto it = data2.map_begin(); it != data2.map_end(); ++it) { const std::string& key = it->first; smart_objects::SmartObject& value = it->second; @@ -305,9 +310,9 @@ smart_objects::SmartObject RCHelpers::MergeModuleData( } // Merge maps and arrays with `id` param included, replace other types - if (value.getType() == smart_objects::SmartType::SmartType_Map) { + if (smart_objects::SmartType::SmartType_Map == value.getType()) { value = MergeModuleData(result[key], value); - } else if (value.getType() == smart_objects::SmartType::SmartType_Array) { + } else if (smart_objects::SmartType::SmartType_Array == value.getType()) { value = MergeArray(result[key], value); } result[key] = value; |