diff --git a/src/bank.cpp b/src/bank.cpp index 9ee1f8c8d..6053937b5 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -72,7 +72,7 @@ void sort_fission_bank() // TODO: C++17 introduces the exclusive_scan() function which could be // used to replace everything above this point in this function. - + // We need a scratch vector to make permutation of the fission bank into // sorted order easy. Under normal usage conditions, the fission bank is // over provisioned, so we can use that as scratch space. @@ -106,6 +106,11 @@ void sort_fission_bank() extern "C" int openmc_source_bank(void** ptr, int64_t* n) { + if (!ptr || !n) { + set_errmsg("Received null pointer."); + return OPENMC_E_INVALID_ARGUMENT; + } + if (simulation::source_bank.size() == 0) { set_errmsg("Source bank has not been allocated."); return OPENMC_E_ALLOCATE; @@ -118,6 +123,11 @@ extern "C" int openmc_source_bank(void** ptr, int64_t* n) extern "C" int openmc_fission_bank(void** ptr, int64_t* n) { + if (!ptr || !n) { + set_errmsg("Received null pointer."); + return OPENMC_E_INVALID_ARGUMENT; + } + if (simulation::fission_bank.size() == 0) { set_errmsg("Fission bank has not been allocated."); return OPENMC_E_ALLOCATE;