summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authoryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-19 03:43:00 (GMT)
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-19 03:43:00 (GMT)
commit548896c927f653429aeea143217ba110620d67e1 (patch)
tree96d17b38dc09f82d4b1947982bc2fe0782d3624c /iseq.c
parent6f3bdbf632dc346203ad63a9aad1bdabe602dd88 (diff)
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
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/iseq.c b/iseq.c
index c01d94f..e03f1f2 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) {