Skip to content
Snippets Groups Projects
Commit acfdfcb7 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[ParL] Add safety check before vector access

The value k could be pointing to the end of the vector if the for loops runs
through without fulfilling the if-condition.
parent e4aac2e5
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,13 @@ std::vector<double> TimeDependentHeterogeneousParameter::operator()( ...@@ -60,6 +60,13 @@ std::vector<double> TimeDependentHeterogeneousParameter::operator()(
break; break;
} }
} }
if (k == _time_parameter_mapping.size())
{
OGS_FATAL(
"Could not find parameter for time {}. There are {:d} "
"time-parameter pairs.",
t, _time_parameter_mapping.size());
}
auto const t0 = _time_parameter_mapping[k - 1].first; auto const t0 = _time_parameter_mapping[k - 1].first;
auto const t1 = _time_parameter_mapping[k].first; auto const t1 = _time_parameter_mapping[k].first;
auto const alpha = (t - t0) / (t1 - t0); auto const alpha = (t - t0) / (t1 - t0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment