summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShobhit Adlakha <ShobhitAd@users.noreply.github.com>2022-03-11 15:52:12 -0500
committerGitHub <noreply@github.com>2022-03-11 15:52:12 -0500
commitc95f2f91b7af6be5adc387cc1f2aba463109f061 (patch)
treef56534e67109076296b3e16055bb533a8f780eae
parent7a3b9bfb9a685d493f9ac4520d30e47296b11273 (diff)
downloadsdl_core-c95f2f91b7af6be5adc387cc1f2aba463109f061.tar.gz
Fix/8.1.0 RC1 Coverity fixes (#3877)
* Fix reported coverity issues * Add null check for message_ptr
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc11
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc17
-rw-r--r--src/components/application_manager/src/mobile_message_handler.cc10
-rw-r--r--src/components/transport_manager/src/cloud/websocket_client_connection.cc4
4 files changed, 14 insertions, 28 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 55a60abea5..486af1de92 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -1959,7 +1959,10 @@ bool ApplicationManagerImpl::StartNaviService(
const ApplicationSet apps = applications().GetData();
for (auto app : apps) {
- if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) {
+ if (!app) {
+ SDL_LOG_ERROR("NULL pointer for application");
+ continue;
+ } else if (!app->is_navi() && !app->mobile_projection_enabled()) {
SDL_LOG_DEBUG("Continue, Not Navi App Id: " << app->app_id());
continue;
}
@@ -3175,12 +3178,6 @@ void ApplicationManagerImpl::SendOnSDLClose() {
(*msg)[strings::params][strings::protocol_version] =
commands::CommandImpl::protocol_version_;
- if (!msg) {
- SDL_LOG_WARN("Null-pointer message received.");
- NOTREACHED();
- return;
- }
-
// SmartObject |message| has no way to declare priority for now
std::shared_ptr<Message> message_to_send(
new Message(protocol_handler::MessagePriority::kDefault));
diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc
index 606bc4c3f0..0a9d8af9da 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -1059,10 +1059,6 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateSetAppIcon(
std::make_shared<smart_objects::SmartObject>(
smart_objects::SmartType_Map);
- if (!set_icon) {
- return NULL;
- }
-
smart_objects::SmartObject& object = *set_icon;
object[strings::sync_file_name][strings::value] = path_to_icon;
// TODO(PV): need to store actual image type
@@ -1419,9 +1415,7 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateAppVrHelp(
smart_objects::SmartObjectSPtr result =
std::make_shared<smart_objects::SmartObject>(
smart_objects::SmartType_Map);
- if (!result) {
- return NULL;
- }
+
smart_objects::SmartObject& vr_help = *result;
const smart_objects::SmartObject* vr_help_title = app->vr_help_title();
if (vr_help_title) {
@@ -2266,9 +2260,6 @@ void MessageHelper::SendGetUserFriendlyMessageResponse(
smart_objects::SmartObjectSPtr message =
std::make_shared<smart_objects::SmartObject>(
smart_objects::SmartType_Map);
- if (!message) {
- return;
- }
(*message)[strings::params][strings::function_id] =
hmi_apis::FunctionID::SDL_GetUserFriendlyMessage;
@@ -3050,9 +3041,6 @@ void MessageHelper::SendGetStatusUpdateResponse(const std::string& status,
smart_objects::SmartObjectSPtr message =
std::make_shared<smart_objects::SmartObject>(
smart_objects::SmartType_Map);
- if (!message) {
- return;
- }
(*message)[strings::params][strings::function_id] =
hmi_apis::FunctionID::SDL_GetStatusUpdate;
@@ -3090,9 +3078,6 @@ void MessageHelper::SendOnStatusUpdate(const std::string& status,
smart_objects::SmartObjectSPtr message =
std::make_shared<smart_objects::SmartObject>(
smart_objects::SmartType_Map);
- if (!message) {
- return;
- }
(*message)[strings::params][strings::function_id] =
hmi_apis::FunctionID::SDL_OnStatusUpdate;
diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc
index a9c0a362be..6cbe5ec25a 100644
--- a/src/components/application_manager/src/mobile_message_handler.cc
+++ b/src/components/application_manager/src/mobile_message_handler.cc
@@ -135,15 +135,15 @@ application_manager::Message*
MobileMessageHandler::HandleIncomingMessageProtocolV1(
const ::protocol_handler::RawMessagePtr message) {
SDL_LOG_AUTO_TRACE();
- application_manager::Message* outgoing_message =
- new application_manager::Message(
- protocol_handler::MessagePriority::FromServiceType(
- message->service_type()));
+
if (!message) {
NOTREACHED();
- delete outgoing_message;
return NULL;
}
+ application_manager::Message* outgoing_message =
+ new application_manager::Message(
+ protocol_handler::MessagePriority::FromServiceType(
+ message->service_type()));
outgoing_message->set_connection_key(message->connection_key());
outgoing_message->set_protocol_version(
diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc
index a84723d2a1..e0fcbd983b 100644
--- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc
+++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc
@@ -315,6 +315,10 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() {
while (!message_queue_.empty()) {
Message message_ptr;
message_queue_.pop(message_ptr);
+ if (!message_ptr) {
+ SDL_LOG_ERROR("Invalid message in message queue");
+ continue;
+ }
if (!shutdown_) {
boost::system::error_code ec;
if (handler_.cloud_properties.cloud_transport_type == "WS") {