ruby-changes:49456
From: ko1 <ko1@a...>
Date: Wed, 3 Jan 2018 00:30:03 +0900 (JST)
Subject: [ruby-changes:49456] ko1:r61571 (trunk): check an existence of block.
ko1 2018-01-03 00:29:58 +0900 (Wed, 03 Jan 2018) New Revision: 61571 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61571 Log: check an existence of block. * gc.c (rb_raw_obj_info): check block before using it. * vm_core.h (vm_block_iseq): r61565 introduced NULL check but this check is only needed by `rb_raw_obj_info()` and it is called at GC debug mode. Above fix for `rb_raw_obj_info()` solves this problem and NULL check should not be needed any more. Modified files: trunk/gc.c trunk/vm_core.h Index: gc.c =================================================================== --- gc.c (revision 61570) +++ gc.c (revision 61571) @@ -9346,8 +9346,12 @@ rb_raw_obj_info(char *buff, const int bu https://github.com/ruby/ruby/blob/trunk/gc.c#L9346 break; } case T_DATA: { + const struct rb_block *block; const rb_iseq_t *iseq; - if (rb_obj_is_proc(obj) && (iseq = vm_proc_iseq(obj)) != NULL) { + if (rb_obj_is_proc(obj) && + (block = vm_proc_block(obj)) != NULL && + (vm_block_type(block) == block_type_iseq) && + (iseq = vm_block_iseq(block)) != NULL) { rb_raw_iseq_info(buff, buff_size, iseq); } else { Index: vm_core.h =================================================================== --- vm_core.h (revision 61570) +++ vm_core.h (revision 61571) @@ -1406,7 +1406,6 @@ vm_proc_ep(VALUE procval) https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1406 static inline const rb_iseq_t * vm_block_iseq(const struct rb_block *block) { - if (!block) return NULL; switch (vm_block_type(block)) { case block_type_iseq: return rb_iseq_check(block->as.captured.code.iseq); case block_type_proc: return vm_proc_iseq(block->as.proc); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/