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 authored and GitHub committed 2025-06-02 15:29:46 +02:00
1 parent afe2434b63
commit 27556f36ae
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 ) );
}