This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Committed: avoid null-pointer dereference in verify_changes


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.

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))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]