[前][次][番号順一覧][スレッド一覧]

ruby-changes:40553

From: nobu <ko1@a...>
Date: Wed, 18 Nov 2015 11:08:24 +0900 (JST)
Subject: [ruby-changes:40553] nobu:r52632 (trunk): compile.c: check type before checking insn_id

nobu	2015-11-18 11:08:17 +0900 (Wed, 18 Nov 2015)

  New Revision: 52632

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52632

  Log:
    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.

  Modified files:
    trunk/compile.c
Index: compile.c
===================================================================
--- compile.c	(revision 52631)
+++ compile.c	(revision 52632)
@@ -1998,7 +1998,13 @@ iseq_peephole_optimize(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/compile.c#L1998
 	 */
 	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)) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]