summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlha Vorobiova (GitHub) <86727408+OlhaVorobiova@users.noreply.github.com>2022-08-23 22:26:06 +0200
committerGitHub <noreply@github.com>2022-08-23 16:26:06 -0400
commitbbb9f0088a808dba7b8a6768b2f02cfef29cc123 (patch)
tree6fdfdf7d0b6a69d6c4eaf3ccaaab2e7cd2f0ed35
parentf8b1dd0e85b023e5b9eb027b3f4c1c7be2194e0f (diff)
downloadsdl_core-bbb9f0088a808dba7b8a6768b2f02cfef29cc123.tar.gz
Check iterator before erase in ProcessResponseFromHMI (#3919)
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data_processor_impl.h3
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_processor_impl.cc15
2 files changed, 14 insertions, 4 deletions
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_processor_impl.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_processor_impl.h
index 312302d157..ffb9359f9c 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_data_processor_impl.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_processor_impl.h
@@ -129,8 +129,9 @@ class ResumptionDataProcessorImpl
* requests
* @param app_id ID of application, related to event
* @param found_request reference to found request
+ * @return true, if request is found and erased
*/
- void EraseProcessedRequest(const uint32_t app_id,
+ bool EraseProcessedRequest(const uint32_t app_id,
const ResumptionRequest& found_request);
/**
diff --git a/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc b/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc
index b8462a533a..7d65ce75c2 100644
--- a/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc
@@ -178,7 +178,7 @@ void ResumptionDataProcessorImpl::ProcessResumptionStatus(
}
}
-void ResumptionDataProcessorImpl::EraseProcessedRequest(
+bool ResumptionDataProcessorImpl::EraseProcessedRequest(
const uint32_t app_id, const ResumptionRequest& found_request) {
SDL_LOG_AUTO_TRACE();
@@ -194,7 +194,11 @@ void ResumptionDataProcessorImpl::EraseProcessedRequest(
request.request_id.function_id ==
found_request.request_id.function_id;
});
- list_of_sent_requests.erase(request_iter);
+ if (request_iter != list_of_sent_requests.end()) {
+ list_of_sent_requests.erase(request_iter);
+ return true;
+ }
+ return false;
}
bool ResumptionDataProcessorImpl::IsResumptionFinished(
@@ -285,6 +289,7 @@ void ResumptionDataProcessorImpl::ProcessResponseFromHMI(
SDL_LOG_DEBUG("app_id is: " << app_id);
auto found_request = GetRequest(app_id, function_id, corr_id);
+
if (!found_request) {
SDL_LOG_ERROR("Request with function id " << function_id << " and corr id "
<< corr_id << " not found");
@@ -293,7 +298,11 @@ void ResumptionDataProcessorImpl::ProcessResponseFromHMI(
auto request = *found_request;
ProcessResumptionStatus(app_id, response, request);
- EraseProcessedRequest(app_id, request);
+
+ if (!EraseProcessedRequest(app_id, request)) {
+ SDL_LOG_DEBUG("Request has already been processed");
+ return;
+ }
if (!IsResumptionFinished(app_id)) {
SDL_LOG_DEBUG("Resumption app "