Make sure std::equal is executed on valid range of vectors

Previous solution did not check for equal length of these vectors, causing out of bounds compare. Detected by debug build using MSVC
This commit is contained in:
Magne Sjaastad committed 2025-06-10 10:52:18 +02:00
1 parent 1ee5a037ec
commit 4eccfc86b5
1 file changed
+3 -10
@@ -77,16 +77,9 @@ void RiaCurveMerger<XValueType>::addCurveData( const std::vector<XValueType>& xV
}
else
{
if ( m_isXValuesSharedBetweenCurves )
{
const auto& firstXValues = m_originalValues.front().first;
m_isXValuesSharedBetweenCurves = std::equal( firstXValues.begin(), firstXValues.end(), xValues.begin() );
}
if ( m_isXValuesMonotonicallyIncreasing )
{
m_isXValuesMonotonicallyIncreasing = isMonotonicallyIncreasing( xValues );
}
const auto& firstXValues = m_originalValues.front().first;
m_isXValuesSharedBetweenCurves &= std::equal( firstXValues.begin(), firstXValues.end(), xValues.begin(), xValues.end() );
m_isXValuesMonotonicallyIncreasing &= isMonotonicallyIncreasing( xValues );
}
m_originalValues.push_back( std::make_pair( xValues, yValues ) );
}