Skip to content

Commit 7ddc5e6

Browse files
committed
Suppress overflow warning at ALLOC_N in iseq_set_local_table
`xmalloc2` checks the overflow of arguments multiplication.
1 parent c5f7d27 commit 7ddc5e6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compile.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,10 @@ iseq_set_local_table(rb_iseq_t *iseq, const rb_ast_id_table_t *tbl, const NODE *
21842184
}
21852185

21862186
if (size > 0) {
2187-
ID *ids = (ID *)ALLOC_N(ID, size);
2187+
#if SIZEOF_INT >= SIZEOF_SIZE_T
2188+
ASSUME(size < SIZE_MAX / sizeof(ID)); /* checked in xmalloc2_size */
2189+
#endif
2190+
ID *ids = ALLOC_N(ID, size);
21882191
MEMCPY(ids, tbl->ids + offset, ID, size);
21892192
ISEQ_BODY(iseq)->local_table = ids;
21902193
}

0 commit comments

Comments
 (0)