From cff48e4456ed67f1debadea38ae1041598b04222 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 2 Jan 2018 15:29:58 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- gc.c | 6 +++++- vm_core.h | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index 140fc5047f..8e4190f352 100644 --- a/gc.c +++ b/gc.c @@ -9346,8 +9346,12 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj) 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 { diff --git a/vm_core.h b/vm_core.h index f2ea983d36..3691d13fa5 100644 --- a/vm_core.h +++ b/vm_core.h @@ -1406,7 +1406,6 @@ vm_proc_ep(VALUE procval) 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);