mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Prevent out-of-bounds memory access on Compton profile data
This commit is contained in:
parent
765df9115f
commit
6ede028b39
1 changed files with 10 additions and 2 deletions
|
|
@ -226,8 +226,9 @@ PhotonInteraction::PhotonInteraction(hid_t group)
|
|||
|
||||
// Create Compton profile CDF
|
||||
auto n_profile = data::compton_profile_pz.size();
|
||||
profile_cdf_ = xt::empty<double>({n_shell, n_profile});
|
||||
for (int i = 0; i < profile_pdf_.shape(0); ++i) {
|
||||
auto n_shell_compton = profile_pdf_.shape(0);
|
||||
profile_cdf_ = xt::empty<double>({n_shell_compton, n_profile});
|
||||
for (int i = 0; i < n_shell_compton; ++i) {
|
||||
double c = 0.0;
|
||||
profile_cdf_(i, 0) = 0.0;
|
||||
for (int j = 0; j < n_profile - 1; ++j) {
|
||||
|
|
@ -409,6 +410,13 @@ void PhotonInteraction::compton_scatter(double alpha, bool doppler,
|
|||
double E_out;
|
||||
this->compton_doppler(alpha, *mu, &E_out, i_shell, seed);
|
||||
*alpha_out = E_out / MASS_ELECTRON_EV;
|
||||
|
||||
// It's possible for the Compton profile data to have more shells than
|
||||
// there are in the ENDF data. Make sure the shell index doesn't end up
|
||||
// out of bounds.
|
||||
if (*i_shell >= shells_.size()) {
|
||||
*i_shell = -1;
|
||||
}
|
||||
} else {
|
||||
*i_shell = -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue