summaryrefslogtreecommitdiff
path: root/vm_backtrace.c
diff options
context:
space:
mode:
author卜部昌平 <[email protected]>2019-10-07 16:56:08 +0900
committer卜部昌平 <[email protected]>2019-10-09 12:12:28 +0900
commit7e0ae1698d4db0baec858a46de8d1ae875360cf5 ()
tree646fbe720b13469679973060b8ab5299cf076236 /vm_backtrace.c
parenta220410be70264a0e4089c4d63a9c22dd688ca7c (diff)
avoid overflow in integer multiplication
This changeset basically replaces `ruby_xmalloc(x * y)` into `ruby_xmalloc2(x, y)`. Some convenient functions are also provided for instance `rb_xmalloc_mul_add(x, y, z)` which allocates x * y + z byes.
Notes: Merged: https://.com/ruby/ruby/pull/2540
-rw-r--r--vm_backtrace.c2
1 files changed, 1 insertions, 1 deletions
@@ -526,7 +526,7 @@ bt_init(void *ptr, size_t size)
struct bt_iter_arg *arg = (struct bt_iter_arg *)ptr;
arg->btobj = backtrace_alloc(rb_cBacktrace);
GetCoreDataFromValue(arg->btobj, rb_backtrace_t, arg->bt);
- arg->bt->backtrace_base = arg->bt->backtrace = ruby_xmalloc(sizeof(rb_backtrace_location_t) * size);
arg->bt->backtrace_size = 0;
}