mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4395 Robustness : Guard array out of bounds access
This commit is contained in:
parent
29ec970b02
commit
ac8ea73c36
@ -118,6 +118,8 @@ const std::vector<double>* RigFlowDiagResults::findOrCalculateResult(const RigFl
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RigFlowDiagResults::calculateNativeResultsIfNotPreviouslyAttempted(size_t timeStepIndex, RigFlowDiagResultAddress::PhaseSelection phaseSelection)
|
void RigFlowDiagResults::calculateNativeResultsIfNotPreviouslyAttempted(size_t timeStepIndex, RigFlowDiagResultAddress::PhaseSelection phaseSelection)
|
||||||
{
|
{
|
||||||
|
if (timeStepIndex >= m_hasAtemptedNativeResults.size()) return;
|
||||||
|
|
||||||
auto it = m_hasAtemptedNativeResults[timeStepIndex].find(phaseSelection);
|
auto it = m_hasAtemptedNativeResults[timeStepIndex].find(phaseSelection);
|
||||||
if ( it == m_hasAtemptedNativeResults[timeStepIndex].end() || !it->second )
|
if ( it == m_hasAtemptedNativeResults[timeStepIndex].end() || !it->second )
|
||||||
{
|
{
|
||||||
@ -701,11 +703,14 @@ double RigFlowDiagResults::maxAbsPairFlux(int timeStepIndex)
|
|||||||
calculateNativeResultsIfNotPreviouslyAttempted(timeStepIndex, RigFlowDiagResultAddress::PHASE_ALL);
|
calculateNativeResultsIfNotPreviouslyAttempted(timeStepIndex, RigFlowDiagResultAddress::PHASE_ALL);
|
||||||
double maxFlux = 0.0;
|
double maxFlux = 0.0;
|
||||||
|
|
||||||
|
if (timeStepIndex < m_injProdPairFluxCommunicationTimesteps.size())
|
||||||
|
{
|
||||||
for (const auto& commPair : m_injProdPairFluxCommunicationTimesteps[timeStepIndex][RigFlowDiagResultAddress::PHASE_ALL])
|
for (const auto& commPair : m_injProdPairFluxCommunicationTimesteps[timeStepIndex][RigFlowDiagResultAddress::PHASE_ALL])
|
||||||
{
|
{
|
||||||
if (fabs(commPair.second.first) > maxFlux ) maxFlux = fabs(commPair.second.first);
|
if (fabs(commPair.second.first) > maxFlux ) maxFlux = fabs(commPair.second.first);
|
||||||
if (fabs(commPair.second.second) > maxFlux ) maxFlux = fabs(commPair.second.second);
|
if (fabs(commPair.second.second) > maxFlux ) maxFlux = fabs(commPair.second.second);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return maxFlux;
|
return maxFlux;
|
||||||
}
|
}
|
||||||
|
@ -113,10 +113,12 @@ RiuFlowCharacteristicsPlot::~RiuFlowCharacteristicsPlot()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuFlowCharacteristicsPlot::setLorenzCurve(const QStringList& dateTimeStrings, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
|
void RiuFlowCharacteristicsPlot::setLorenzCurve(const QStringList& dateTimeStrings, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
|
||||||
{
|
{
|
||||||
initializeColors(dateTimes);
|
|
||||||
|
|
||||||
m_lorenzPlot->detachItems(QwtPlotItem::Rtti_PlotCurve, true);
|
m_lorenzPlot->detachItems(QwtPlotItem::Rtti_PlotCurve, true);
|
||||||
|
|
||||||
|
if (!dateTimes.empty())
|
||||||
|
{
|
||||||
|
initializeColors(dateTimes);
|
||||||
|
|
||||||
for (size_t tsIdx = 0; tsIdx < dateTimes.size(); ++tsIdx)
|
for (size_t tsIdx = 0; tsIdx < dateTimes.size(); ++tsIdx)
|
||||||
{
|
{
|
||||||
if (timeHistoryValues[tsIdx] == HUGE_VAL) continue;
|
if (timeHistoryValues[tsIdx] == HUGE_VAL) continue;
|
||||||
@ -128,6 +130,7 @@ void RiuFlowCharacteristicsPlot::setLorenzCurve(const QStringList& dateTimeStrin
|
|||||||
|
|
||||||
RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(m_lorenzPlot, curveName, m_dateToColorMap[dateTime], dateTime, timeHistoryValue);
|
RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(m_lorenzPlot, curveName, m_dateToColorMap[dateTime], dateTime, timeHistoryValue);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_lorenzPlot->replot();
|
m_lorenzPlot->replot();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user