From 0eff21af8d03a9d2b881b9cce963262da3d952dc Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Thu, 23 May 2019 11:19:23 +0900 Subject: [PATCH] update Array's length correctly. ARRAY_ASET() does not change the length of array, so use rb_ary_push() instead of ARRAY_ASET(). It prevents updating reference on GC.compact. --- vm_args.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm_args.c b/vm_args.c index e9a1a8c580..96fca84cf4 100644 --- a/vm_args.c +++ b/vm_args.c @@ -902,8 +902,8 @@ vm_caller_setup_arg_block(const rb_execution_context_t *ec, rb_control_frame_t * if (NIL_P(func)) { /* TODO: limit cached funcs */ VALUE callback_arg = rb_ary_tmp_new(2); - RARRAY_ASET(callback_arg, 0, block_code); - RARRAY_ASET(callback_arg, 1, ref); + rb_ary_push(callback_arg, block_code); + rb_ary_push(callback_arg, ref); OBJ_FREEZE_RAW(callback_arg); func = rb_func_proc_new(refine_sym_proc_call, callback_arg); rb_hash_aset(ref, block_code, func);