diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-18 02:08:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-18 02:08:17 +0000 |
commit | b1e70025aa1232ff1a9dcddbdfebd5bbb1c8657a (patch) | |
tree | fc0aedbc5597150c1a539e8046c1722246a4fef9 | |
parent | 993289c197e442859c9b580040715ce3e397872e (diff) | |
download | ruby-b1e70025aa1232ff1a9dcddbdfebd5bbb1c8657a.tar.gz |
compile.c: check type before checking insn_id
* compile.c (iseq_peephole_optimize): check element type before
checking insn_id which is valid only for INSN elements.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | compile.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1998,7 +1998,13 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal */ INSN *nobj = (INSN *)get_destination_insn(iobj); INSN *pobj = (INSN *)iobj->link.prev; - int prev_dup = (pobj && pobj->insn_id == BIN(dup)); + int prev_dup = 0; + if (pobj) { + if (pobj->link.type != ISEQ_ELEMENT_INSN) + pobj = 0; + else if (pobj->insn_id == BIN(dup)) + prev_dup = 1; + } for (;;) { if (nobj->insn_id == BIN(jump)) { |