mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
In some unit tests, OpenMC finalize is called twice in a row without re-initializing the whole simulation. This caused the shared fission bank to be freed twice. Fixed now to check if it is a null pointer, and only free if null. Also initializes this value to null and sets it to null after freeing.
This commit is contained in:
parent
ad96fa6ffa
commit
1f3bc2c4d3
1 changed files with 4 additions and 2 deletions
|
|
@ -19,7 +19,7 @@ namespace simulation {
|
|||
std::vector<Particle::Bank> source_bank;
|
||||
std::vector<Particle::Bank> fission_bank;
|
||||
|
||||
Particle::Bank* shared_fission_bank;
|
||||
Particle::Bank* shared_fission_bank {nullptr};
|
||||
int shared_fission_bank_length {0};
|
||||
int shared_fission_bank_max;
|
||||
|
||||
|
|
@ -33,7 +33,9 @@ void free_memory_bank()
|
|||
{
|
||||
simulation::source_bank.clear();
|
||||
simulation::fission_bank.clear();
|
||||
delete[] simulation::shared_fission_bank;
|
||||
if( simulation::shared_fission_bank != nullptr )
|
||||
delete[] simulation::shared_fission_bank;
|
||||
simulation::shared_fission_bank = nullptr;
|
||||
simulation::shared_fission_bank_length = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue