From 0a91fea676bad492e31d9828c3bf52ff8b9d17dc Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Wed, 29 Jan 2025 12:54:41 +0100 Subject: [PATCH] lte: End check before dereference and handle cell removals --- src/lte/model/cqa-ff-mac-scheduler.cc | 3 ++- src/lte/model/lte-ffr-enhanced-algorithm.cc | 4 ++-- src/lte/model/lte-ue-rrc.cc | 16 ++-------------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/lte/model/cqa-ff-mac-scheduler.cc b/src/lte/model/cqa-ff-mac-scheduler.cc index 8f02fa7ea..1f51d68c3 100644 --- a/src/lte/model/cqa-ff-mac-scheduler.cc +++ b/src/lte/model/cqa-ff-mac-scheduler.cc @@ -1495,7 +1495,8 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } qos_rb_and_CQI_assigned_to_lc s; - s.cqi_value_for_lc = UeToCQIValue.find(userWithMaximumMetric)->second; + const auto ueToCqiIt = UeToCQIValue.find(userWithMaximumMetric); + s.cqi_value_for_lc = ueToCqiIt != UeToCQIValue.end() ? ueToCqiIt->second : 1; s.resource_block_index = currentRB; auto itMap = allocationMapPerRntiPerLCId.find(userWithMaximumMetric.m_rnti); diff --git a/src/lte/model/lte-ffr-enhanced-algorithm.cc b/src/lte/model/lte-ffr-enhanced-algorithm.cc index ce3c1f893..3d74f3363 100644 --- a/src/lte/model/lte-ffr-enhanced-algorithm.cc +++ b/src/lte/model/lte-ffr-enhanced-algorithm.cc @@ -736,10 +736,10 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( for (uint32_t j = 0; j < dlRbgAvailableMap.size(); j++) { uint32_t index = rbgSize * j; - for (uint32_t i = 0; i < rbgSize; i++) + for (uint32_t i = 0; i < rbgSize && index < m_ulBandwidth; i++) { - index = index + i; ulRbAvailableMap[index] = dlRbgAvailableMap[j]; + index++; } } diff --git a/src/lte/model/lte-ue-rrc.cc b/src/lte/model/lte-ue-rrc.cc index 2234d710e..818bfdb9f 100644 --- a/src/lte/model/lte-ue-rrc.cc +++ b/src/lte/model/lte-ue-rrc.cc @@ -2678,13 +2678,7 @@ LteUeRrc::CancelEnteringTrigger(uint8_t measId, uint16_t cellId) { NS_ASSERT(it2->measId == measId); - for (auto it3 = it2->concernedCells.begin(); it3 != it2->concernedCells.end(); ++it3) - { - if (*it3 == cellId) - { - it3 = it2->concernedCells.erase(it3); - } - } + it2->concernedCells.remove_if([cellId](auto cell) { return cellId == cell; }); if (it2->concernedCells.empty()) { @@ -2735,13 +2729,7 @@ LteUeRrc::CancelLeavingTrigger(uint8_t measId, uint16_t cellId) { NS_ASSERT(it2->measId == measId); - for (auto it3 = it2->concernedCells.begin(); it3 != it2->concernedCells.end(); ++it3) - { - if (*it3 == cellId) - { - it3 = it2->concernedCells.erase(it3); - } - } + it2->concernedCells.remove_if([cellId](auto cell) { return cellId == cell; }); if (it2->concernedCells.empty()) {