Patchwork Committed: avoid null-pointer dereference in verify_changes

login
register
mail settings
Submitter Joern Rennecke
Date Aug. 30, 2013, 2:26 p.m.
Message ID <20130830102601.rbgh6p005k4004cg-nzlynne@webmail.spamcop.net>
Download mbox | patch
Permalink /patch/271300/
State New
Headers show

Comments

Joern Rennecke - Aug. 30, 2013, 2:26 p.m.
I got nine ICEs in verify_changes for compile/20110401-1.c on ARC.

Fixed by checking changes[i].old before dereferencing it.

Bootstrapped on i686-pc-linux.gnu.

Committed as obvious.
2013-05-20  Joern Rennecke  <joern.rennecke@embecosm.com>

            * recog.c (verify_changes): Verify that changes[i].old is non-zero
            before applying REG_P.

Patch

Index: recog.c
===================================================================
--- recog.c	(revision 202106)
+++ recog.c	(working copy)
@@ -397,7 +397,10 @@  verify_changes (int num)
 					     MEM_ADDR_SPACE (object)))
 	    break;
 	}
-      else if (REG_P (changes[i].old)
+      else if (/* changes[i].old might be zero, e.g. when putting a
+	       REG_FRAME_RELATED_EXPR into a previously empty list.  */
+	       changes[i].old
+	       && REG_P (changes[i].old)
 	       && asm_noperands (PATTERN (object)) > 0
 	       && REG_EXPR (changes[i].old) != NULL_TREE
 	       && DECL_ASSEMBLER_NAME_SET_P (REG_EXPR (changes[i].old))