Skip to content

Commit f3f06b3

Browse files
committed
ATRONIX: Use macros for overflow detection
(cherry picked from commit ac2b240)
1 parent 7eca4c3 commit f3f06b3

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/core/m-series.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
***********************************************************************/
2828

2929
#include "sys-core.h"
30+
#include "sys-int-funcs.h"
3031

3132

3233
/***********************************************************************
@@ -112,13 +113,9 @@
112113
#ifdef DEBUGGING
113114
Print_Num("Expand:", series->tail + delta + 1);
114115
#endif
115-
new_size = series->tail + delta + x;
116-
if (new_size < series->tail
117-
|| new_size < delta
118-
|| new_size < x
119-
|| new_size < series->tail + delta
120-
|| new_size < series->tail + x
121-
|| new_size < delta + x) {
116+
/* new_size = series->tail + delta + x with overflow checking */
117+
if (REB_U32_ADD_OF(series->tail, delta, &new_size)
118+
|| REB_U32_ADD_OF(new_size, x, &new_size)) {
122119
Trap0(RE_PAST_END);
123120
}
124121

0 commit comments

Comments
 (0)