From f7949cc404713b93a6f41ad3de314de0b69bb017 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Fri, 15 Nov 2024 05:40:34 -0600 Subject: [PATCH] Avoid invalid iterator comparison after objects mutex is unlocked --- wxdata/source/scwx/provider/aws_nexrad_data_provider.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wxdata/source/scwx/provider/aws_nexrad_data_provider.cpp b/wxdata/source/scwx/provider/aws_nexrad_data_provider.cpp index 4e139bac..c4ac523b 100644 --- a/wxdata/source/scwx/provider/aws_nexrad_data_provider.cpp +++ b/wxdata/source/scwx/provider/aws_nexrad_data_provider.cpp @@ -183,6 +183,7 @@ AwsNexradDataProvider::GetTimePointsByDate( std::shared_lock lock(p->objectsMutex_); // Is the date present in the date list? + bool currentDatePresent; auto currentDateIterator = std::find(p->objectDates_.cbegin(), p->objectDates_.cend(), day); if (currentDateIterator == p->objectDates_.cend()) @@ -199,6 +200,12 @@ AwsNexradDataProvider::GetTimePointsByDate( // Re-lock mutex lock.lock(); + + currentDatePresent = false; + } + else + { + currentDatePresent = true; } // Determine objects to retrieve @@ -216,7 +223,7 @@ AwsNexradDataProvider::GetTimePointsByDate( // If we haven't updated the most recently queried dates yet, because the // date was already cached, update - if (currentDateIterator != p->objectDates_.cend()) + if (currentDatePresent) { p->UpdateObjectDates(date); }