Skip to content

Commit

Permalink
fix potential dereferencing of null
Browse files Browse the repository at this point in the history
identified by coverity
  • Loading branch information
zingale committed Apr 3, 2024
1 parent 6930369 commit fd5c944
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Source/gravity/Gravity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2966,17 +2966,21 @@ Gravity::set_mass_offset (Real time, bool multi_level) const
{
for (int lev = 0; lev <= parent->finestLevel(); lev++) {
auto* cs = dynamic_cast<Castro*>(&parent->getLevel(lev));
if (cs != nullptr) {
mass_offset += cs->volWgtSum("density", time);
} else {
if (cs != nullptr) {
mass_offset += cs->volWgtSum("density", time);
} else {
amrex::Abort("unable to access volWgtSum");
}
}
}
else
{
auto* cs = dynamic_cast<Castro*>(&parent->getLevel(0));
mass_offset = cs->volWgtSum("density", time, false, false); // do not mask off fine grids
if (cs != nullptr) {
mass_offset = cs->volWgtSum("density", time, false, false); // do not mask off fine grids
} else {
amrex::Abort("unable to access volWgtSum");
}
}

mass_offset = mass_offset / geom.ProbSize();
Expand Down

0 comments on commit fd5c944

Please sign in to comment.