diff options
author | jacobkeeler <jacob.keeler@livioradio.com> | 2017-08-14 15:44:32 -0400 |
---|---|---|
committer | jacobkeeler <jacob.keeler@livioradio.com> | 2017-08-14 15:44:32 -0400 |
commit | 19a7dc5dc54c8b0cb9075d7432adb76b628943f2 (patch) | |
tree | 494e8e596ea93bc22d6711ff7f48708bacafc2e6 /src/components/protocol_handler/src/protocol_handler_impl.cc | |
parent | f74a95b4c8730cf362b1b3dceecf2fe05c262818 (diff) | |
download | sdl_core-19a7dc5dc54c8b0cb9075d7432adb76b628943f2.tar.gz |
Fix crash related to previous refactoring
The `protocolVersion` parameter was being read from `start_session_act_params`, which was not populated in the `RPC` service case. This change fixes this and adds a check to make sure that the parameter exists before constructing a version object from the payload.
Diffstat (limited to 'src/components/protocol_handler/src/protocol_handler_impl.cc')
-rw-r--r-- | src/components/protocol_handler/src/protocol_handler_impl.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 0f0aca69ba..17408b44b0 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -1538,8 +1538,11 @@ void ProtocolHandlerImpl::NotifySessionStartedResult( // could still be a payload, in which case we can get the real protocol // version if (packet->service_type() == kRpc && packet->data() != NULL) { - fullVersion = new ProtocolPacket::ProtocolVersion( - std::string(bson_object_get_string(&start_session_ack_params, strings::protocol_version))); + BsonObject request_params = bson_object_from_bytes(packet->data()); + char* version_param = + bson_object_get_string(&request_params, strings::protocol_version); + std::string version_string(version_param == NULL ? "" : version_param); + fullVersion = new ProtocolPacket::ProtocolVersion(version_string); // Constructed payloads added in Protocol v5 if (fullVersion->majorVersion < PROTOCOL_VERSION_5) { rejected_params.push_back(std::string(strings::protocol_version)); |