From 548896c927f653429aeea143217ba110620d67e1 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sat, 19 May 2018 03:43:00 +0000 Subject: iseq.c: Fix segfault when debug is not 0 * iseq.c (get_insn_info_succinct_bitvector): If VM_CHECK_MODE is 0, `body->insns_info.positions` is freed in `rb_iseq_insns_info_encode_positions`. Print `position` only when VM_CHECK_MODE is set. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- iseq.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'iseq.c') diff --git a/iseq.c b/iseq.c index c01d94f9d3..e03f1f2a98 100644 --- a/iseq.c +++ b/iseq.c @@ -1503,13 +1503,19 @@ get_insn_info_succinct_bitvector(const rb_iseq_t *iseq, size_t pos) const struct rb_iseq_constant_body *const body = iseq->body; size_t size = body->insns_info.size; const struct iseq_insn_info_entry *insns_info = body->insns_info.body; - const unsigned int *positions = body->insns_info.positions; const int debug = 0; if (debug) { - printf("size: %"PRIuSIZE"\n", size); - printf("insns_info[%"PRIuSIZE"]: position: %d, line: %d, pos: %"PRIuSIZE"\n", - (size_t)0, positions[0], insns_info[0].line_no, pos); +#if VM_CHECK_MODE > 0 + const unsigned int *positions = body->insns_info.positions; + printf("size: %"PRIuSIZE"\n", size); + printf("insns_info[%"PRIuSIZE"]: position: %d, line: %d, pos: %"PRIuSIZE"\n", + (size_t)0, positions[0], insns_info[0].line_no, pos); +#else + printf("size: %"PRIuSIZE"\n", size); + printf("insns_info[%"PRIuSIZE"]: line: %d, pos: %"PRIuSIZE"\n", + (size_t)0, insns_info[0].line_no, pos); +#endif } if (size == 0) { -- cgit v1.2.3