summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--darray.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/darray.h b/darray.h
index 3c6680b7c4..e4fdfdb123 100644
--- a/darray.h
+++ b/darray.h
@@ -187,12 +187,11 @@ rb_darray_calloc_mul_add_without_gc(size_t x, size_t y, size_t z)
return ptr;
}
-/* Internal function. Like rb_xrealloc_mul_add but does not trigger GC and does
- * not check for overflow in arithmetic. */
+/* Internal function. Like rb_xrealloc_mul_add but does not trigger GC. */
static inline void *
rb_darray_realloc_mul_add_without_gc(const void *orig_ptr, size_t x, size_t y, size_t z)
{
- size_t size = (x * y) + z;
+ size_t size = rbimpl_size_add_or_raise(rbimpl_size_mul_or_raise(x, y), z);
void *ptr = realloc((void *)orig_ptr, size);
if (ptr == NULL) rb_bug("rb_darray_realloc_mul_add_without_gc: failed");