1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-08-11 14:03:56 -04:00

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 <rgetz503@gmail.com>
This commit is contained in:
Robin Getz
2026-08-01 22:41:23 -04:00
parent c170e03ddd
commit e6c3cecb64
+7 -6
View File
@@ -725,6 +725,12 @@ void ScopeVis::processTrace(const std::vector<ComplexVector::const_iterator>& 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