aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compile.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 2d47082618..f66f12e94b 100644
--- a/compile.c
+++ b/compile.c
@@ -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)) {