Fix invalid memory read, from @akohlmey

This commit is contained in:
Stan Gerald Moore
2023-01-27 14:43:16 -07:00
parent 0677c1c3f5
commit e0f090aa9e
2 changed files with 2 additions and 2 deletions

View File

@ -60,7 +60,7 @@ namespace ReaxFF {
hbond_list = hbonds->select.hbond_list;
for (j = 0; j < system->n; ++j)
if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) {
if ((system->my_atoms[j].type >= 0) && (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1)) {
type_j = system->my_atoms[j].type;
start_j = Start_Index(j, bonds);
end_j = End_Index(j, bonds);

View File

@ -56,7 +56,7 @@ namespace ReaxFF {
if (control->hbond_cut > 0)
for (i = 0; i < system->n; ++i) {
atom = &(system->my_atoms[i]);
if (system->reax_param.sbp[atom->type].p_hbond == 1 && atom->type >= 0)
if ((atom->type >= 0) && (system->reax_param.sbp[atom->type].p_hbond == 1 && atom->type >= 0))
atom->Hindex = system->numH++;
else atom->Hindex = -1;
}