Skip to content

Commit 1fbe49d

Browse files
committed
Fixed segfault when which_unimolecular is called for
RX_ABSORB_REGION_BORDER
1 parent f436089 commit 1fbe49d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/react_cond.c

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ int which_unimolecular(struct rxn *rx, struct abstract_molecule *a,
6868

6969
int max = rx->n_pathways - 1;
7070
double match = rng_dbl(rng);
71+
if (rx->n_pathways < 0) {
72+
// related to MCELL3_UNIMOL_RX_ABSORB_NO_RNG
73+
// calling RNG to maintain compatibility but we must avoid invalid memory access
74+
return 0;
75+
}
7176
match = match * rx->cum_probs[max];
7277
return binary_search_double(rx->cum_probs, match, max, 1);
7378
}

0 commit comments

Comments
 (0)