summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-06-21 14:05:46 -0400
committerGitHub <noreply@github.com>2018-06-21 14:05:46 -0400
commitac8b1c5334cd05797c271cff452c2d87f433004c (patch)
tree56c6a62607138fb6c13fca666a5b47f2e067bd24
parent2ec732c56e3f06b7043cf02cf98109720d6ff38a (diff)
parent1dd1640ec5673cda85039b20b3999169bc357511 (diff)
downloadsdl_core-ac8b1c5334cd05797c271cff452c2d87f433004c.tar.gz
Merge pull request #2286 from smartdevicelink/fix/check_onhmistatus_invalid
avoid returning null hmiLevel
-rw-r--r--src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc
index 5225002652..a7453686e6 100644
--- a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc
@@ -57,6 +57,15 @@ void OnHMIStatusNotification::Run() {
return;
}
+ // If the response has no hmi level, return and don't send the notification
+ if (!(*message_)[strings::msg_params].keyExists(strings::hmi_level)) {
+ // our notification clearly isn't well-formed
+ LOG4CXX_ERROR(logger_, "OnHMIStatusNotification has no hmiLevel field");
+ return;
+ }
+
+ // NOTE c++ maps default-construct on the [] operator, so if there is no
+ // hmiLevel field this will create one that is invalid
mobile_apis::HMILevel::eType hmi_level =
static_cast<mobile_apis::HMILevel::eType>(
(*message_)[strings::msg_params][strings::hmi_level].asInt());