From e6c3cecb646f7b8de6323e04b443d36c9d9e6e2c Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 1 Aug 2026 22:41:23 -0400 Subject: [PATCH] scope: Check for empty trigger list before indexing Move the existing empty-trigger check ahead of the access to the current trigger condition. The previous code indexed m_triggerConditions before verifying that the container was non-empty, which could result in an out-of-bounds access. No functional behavior is changed for the non-empty case. noticed by cppcheck : Access out of bounds Signed-off-by: Robin Getz --- sdrbase/dsp/scopevis.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sdrbase/dsp/scopevis.cpp b/sdrbase/dsp/scopevis.cpp index d69297bac..8ba401eb2 100644 --- a/sdrbase/dsp/scopevis.cpp +++ b/sdrbase/dsp/scopevis.cpp @@ -725,6 +725,12 @@ void ScopeVis::processTrace(const std::vector& vc bool ScopeVis::nextTrigger() { + if (m_triggerConditions.empty()) + { + m_currentTriggerIndex = 0; + return false; // final + } + TriggerCondition *triggerCondition = m_triggerConditions[m_currentTriggerIndex]; // current trigger condition if (triggerCondition->m_triggerData.m_triggerRepeat > 0) @@ -740,12 +746,7 @@ bool ScopeVis::nextTrigger() } } - if (m_triggerConditions.size() == 0) - { - m_currentTriggerIndex = 0; - return false; // final - } - else if (m_currentTriggerIndex < m_triggerConditions.size() - 1) // check if next trigger is available + if (m_currentTriggerIndex < m_triggerConditions.size() - 1) // check if next trigger is available { m_currentTriggerIndex++; return true; // not final keep going