mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-25 20:45:35 -04:00
Correct index check for remove_tally. Refs #2493
This commit is contained in:
parent
a12480400b
commit
646ef6d322
1 changed files with 3 additions and 4 deletions
|
|
@ -1280,12 +1280,11 @@ extern "C" size_t tallies_size()
|
|||
extern "C" int openmc_remove_tally(int32_t index)
|
||||
{
|
||||
// check that id is in the map
|
||||
if (index < 0 || index > model::tallies.size()) {
|
||||
if (index < 0 || index >= model::tallies.size()) {
|
||||
set_errmsg("Index in tallies array is out of bounds.");
|
||||
return OPENMC_E_OUT_OF_BOUNDS;
|
||||
}
|
||||
// grab tally so it's ID can be obtained to remove the (ID,index) pair from
|
||||
// tally_map
|
||||
auto& tally = model::tallies[index];
|
||||
|
||||
// delete the tally via iterator pointing to correct position
|
||||
// this calls the Tally destructor, removing the tally from the map as well
|
||||
model::tallies.erase(model::tallies.begin() + index);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue