#1926 Fishbones Export : Guard input values to std::vector::reserve()

This commit is contained in:
Magne Sjaastad 2017-09-22 13:10:09 +02:00
parent d83c468033
commit edd39b6ff1

View File

@ -138,21 +138,25 @@ void RigEclipseWellLogExtractor::curveData(const RigResultAccessor* resultAccess
std::vector<WellPathCellIntersectionInfo> RigEclipseWellLogExtractor::cellIntersectionInfo()
{
std::vector<WellPathCellIntersectionInfo> cellIntersectionInfos;
cellIntersectionInfos.reserve(m_intersections.size()-1);
for (size_t cpIdx = 0; cpIdx < m_intersections.size()-1; ++cpIdx)
if (m_intersections.size() > 1)
{
size_t cellIdx1 = m_intersectedCells[cpIdx];
size_t cellIdx2 = m_intersectedCells[cpIdx+1];
if (cellIdx1 == cellIdx2)
cellIntersectionInfos.reserve(m_intersections.size()-1);
for (size_t cpIdx = 0; cpIdx < m_intersections.size()-1; ++cpIdx)
{
cvf::Vec3d internalCellLengths;
internalCellLengths = RigWellPathIntersectionTools::calculateLengthInCell( m_caseData->mainGrid(), cellIdx1, m_intersections[cpIdx], m_intersections[cpIdx+1] );
size_t cellIdx1 = m_intersectedCells[cpIdx];
size_t cellIdx2 = m_intersectedCells[cpIdx+1];
cellIntersectionInfos.push_back(WellPathCellIntersectionInfo(cellIdx1, m_intersections[cpIdx], m_intersections[cpIdx+1], internalCellLengths));
if (cellIdx1 == cellIdx2)
{
cvf::Vec3d internalCellLengths;
internalCellLengths = RigWellPathIntersectionTools::calculateLengthInCell( m_caseData->mainGrid(), cellIdx1, m_intersections[cpIdx], m_intersections[cpIdx+1] );
cellIntersectionInfos.push_back(WellPathCellIntersectionInfo(cellIdx1, m_intersections[cpIdx], m_intersections[cpIdx+1], internalCellLengths));
}
}
}
}
return cellIntersectionInfos;
}