From c263ae9b66266e8ee7dfb1d166de1a8f3ff83ae4 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 1 Apr 2024 21:34:42 +0200 Subject: [PATCH] fixed: out-of-bounds reference with no wells --- opm/simulators/wells/WellState.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/opm/simulators/wells/WellState.cpp b/opm/simulators/wells/WellState.cpp index 71418c905..d33b5f46b 100644 --- a/opm/simulators/wells/WellState.cpp +++ b/opm/simulators/wells/WellState.cpp @@ -863,7 +863,9 @@ void WellState::communicateGroupRates(const Comm& comm) data[pos++] = 0; } } - pos += this->alq_state.pack_data(&data[pos]); + if (!data.empty()) { + pos += this->alq_state.pack_data(&data[pos]); + } assert(pos == sz); // Communicate it with a single sum() call. @@ -877,7 +879,9 @@ void WellState::communicateGroupRates(const Comm& comm) for (auto& value : rates) value = data[pos++]; } - pos += this->alq_state.unpack_data(&data[pos]); + if (!data.empty()) { + pos += this->alq_state.unpack_data(&data[pos]); + } assert(pos == sz); }