summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kutsan <akutsan@luxoft.com>2017-08-31 23:13:51 +0300
committerAlexander Kutsan <akutsan@luxoft.com>2017-08-31 23:58:35 +0300
commitef1017068fc585883ae5682b8b3fd975e64ae2ca (patch)
tree502afc400cd8ecf1377adb6a4185626aaf23d16d
parent07f95a75fc75b22325e1cb6b65b27c028dc7e425 (diff)
downloadsdl_core-ef1017068fc585883ae5682b8b3fd975e64ae2ca.tar.gz
Fix undefined behaviour in several cases
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc5
-rw-r--r--src/components/remote_control/src/commands/set_interior_vehicle_data_request.cc10
-rw-r--r--src/components/remote_control/src/resource_allocation_manager_impl.cc20
3 files changed, 20 insertions, 15 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 7bee58fd42..b6193b018e 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -4051,7 +4051,10 @@ struct TakeDeviceHandle {
ApplicationSharedPtr ApplicationManagerImpl::application(
const std::string& device_id, const std::string& policy_app_id) const {
connection_handler::DeviceHandle device_handle;
- connection_handler().GetDeviceID(device_id, &device_handle);
+ if (!connection_handler().GetDeviceID(device_id, &device_handle)) {
+ LOG4CXX_DEBUG(logger_, "No such device : " << device_id);
+ return ApplicationSharedPtr();
+ }
DataAccessor<ApplicationSet> accessor = applications();
ApplicationSharedPtr app =
diff --git a/src/components/remote_control/src/commands/set_interior_vehicle_data_request.cc b/src/components/remote_control/src/commands/set_interior_vehicle_data_request.cc
index d88e522ac1..70fbd9280e 100644
--- a/src/components/remote_control/src/commands/set_interior_vehicle_data_request.cc
+++ b/src/components/remote_control/src/commands/set_interior_vehicle_data_request.cc
@@ -332,16 +332,16 @@ std::vector<std::string> SetInteriorVehicleDataRequest::ControlData(
const Json::Value& message) {
Json::Value data =
message.get(message_params::kModuleData, Json::Value(Json::objectValue));
- const char* name_control_data;
std::string module = ModuleType(message);
+ Json::Value params;
if (module == enums_value::kRadio) {
- name_control_data = message_params::kRadioControlData;
+ params = data.get(message_params::kRadioControlData,
+ Json::Value(Json::objectValue));
}
if (module == enums_value::kClimate) {
- name_control_data = message_params::kClimateControlData;
+ params = data.get(message_params::kClimateControlData,
+ Json::Value(Json::objectValue));
}
- Json::Value params =
- data.get(name_control_data, Json::Value(Json::objectValue));
return params.getMemberNames();
}
diff --git a/src/components/remote_control/src/resource_allocation_manager_impl.cc b/src/components/remote_control/src/resource_allocation_manager_impl.cc
index ba77b75600..fd6c2d8fb8 100644
--- a/src/components/remote_control/src/resource_allocation_manager_impl.cc
+++ b/src/components/remote_control/src/resource_allocation_manager_impl.cc
@@ -226,15 +226,17 @@ void ResourceAllocationManagerImpl::SetResourceState(
const AllocatedResources::const_iterator allocated_it =
allocated_resources_.find(module_type);
- const std::string status = allocated_resources_.end() != allocated_it
- ? " acquired "
- : " not acquired ";
- UNUSED(status);
- LOG4CXX_DEBUG(logger_,
- "Resource " << module_type << " is " << status
- << " Owner application id is "
- << allocated_it->second
- << " Changing application id is " << app_id);
+ const bool acquired = allocated_resources_.end() != allocated_it;
+ if (acquired) {
+ LOG4CXX_DEBUG(logger_,
+ "Resource " << module_type << " is already acquired."
+ << " Owner application id is "
+ << allocated_it->second
+ << " Changing application id is " << app_id);
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "Resource " << module_type << " is not acquired yet");
+ }
}
sync_primitives::AutoLock lock(resources_state_lock_);