mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
RiaCurveMerger::addCurveData and RiaWellLogCurveMerger::addCurveData only validated that the X and Y vectors have the same size with CAF_ASSERT, which is compiled out in optimized builds. Mismatching sizes are a legitimate run-time condition for data read from file, so the check has to hold in release builds as well. In RiaCurveMerger the shared-X fast path in computeInterpolatedValues() indexes the Y vector of every curve using the sample count of the first curve. A curve with identical X values but fewer Y values therefore read past the end of its heap buffer inside the OpenMP loop. RimEnsembleStatisticsCase passes time steps and values straight from the summary reader without reconciling the sizes, and realizations in an ensemble normally share time steps, so this was reachable for an ensemble containing an ongoing simulation. Both mergers now truncate the incoming data to the common sample count instead. For RiaWellLogCurveMerger this is also an improvement in behaviour, since lookupYValue() used to discard the whole curve when the sizes differed. Add unit tests covering a single curve with fewer values than time steps and curves with shared time steps where one curve has fewer values.