From 9f9948434737c73dd940d503fb3ec8fbb676655c Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 6 May 2016 21:40:33 +0200 Subject: [PATCH] Prevent dereferencing the end iterator. This happened for empty regions and surfaced when compiling with "-D_GLIBCXX_DEBUG -DDEBUG -DGLIBCXX_FORCE_NEW". --- opm/core/simulator/initStateEquil.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index 2e539ea49..2b4b02b1f 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -264,6 +264,11 @@ namespace Opm if (deck->hasKeyword("DISGAS")) { const TableContainer& rsvdTables = tables.getRsvdTables(); for (size_t i = 0; i < rec.size(); ++i) { + if (eqlmap.cells(i).empty()) + { + rs_func_.push_back(std::shared_ptr()); + continue; + } const int cell = *(eqlmap.cells(i).begin()); if (!rec[i].liveOilInitConstantRs()) { if (rsvdTables.size() <= 0 ) { @@ -297,6 +302,11 @@ namespace Opm if (deck->hasKeyword("VAPOIL")) { const TableContainer& rvvdTables = tables.getRvvdTables(); for (size_t i = 0; i < rec.size(); ++i) { + if (eqlmap.cells(i).empty()) + { + rv_func_.push_back(std::shared_ptr()); + continue; + } const int cell = *(eqlmap.cells(i).begin()); if (!rec[i].wetGasInitConstantRv()) { if (rvvdTables.size() <= 0) { @@ -381,6 +391,10 @@ namespace Opm { for (const auto& r : reg.activeRegions()) { const auto& cells = reg.cells(r); + if (cells.empty()) + { + continue; + } const int repcell = *cells.begin(); const RhoCalc calc(props, repcell);