aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/gc.c b/gc.c
index a3af6fefbb..cd8682547a 100644
--- a/gc.c
+++ b/gc.c
@@ -7649,16 +7649,16 @@ ruby_xmalloc(size_t size)
return objspace_xmalloc(&rb_objspace, size);
}
-static inline size_t
-xmalloc2_size(size_t n, size_t size)
+void
+ruby_malloc_size_overflow(size_t count, size_t elsize)
{
- size_t len = size * n;
- if (n != 0 && size != len / n) {
- rb_raise(rb_eArgError, "malloc: possible integer overflow");
- }
- return len;
+ rb_raise(rb_eArgError,
+ "malloc: possible integer overflow (%"PRIdSIZE"*%"PRIdSIZE")",
+ count, elsize);
}
+#define xmalloc2_size ruby_xmalloc2_size
+
void *
ruby_xmalloc2(size_t n, size_t size)
{