Patchwork [v2] genattrtab: avoid NULL-deref on error

login
register
mail settings
Submitter Jim Meyering
Date Feb. 24, 2012, 5:03 p.m.
Message ID <87ehtk410o.fsf@rho.meyering.net>
Download mbox | patch
Permalink /patch/142949/
State New
Headers show

Comments

Jim Meyering - Feb. 24, 2012, 5:03 p.m.
This is the same as the preceding patch, but fixes
s/defin_enum/define_enum/ in the ChangeLog comment:

2012-02-24  Jim Meyering  <meyering@redhat.com>

	* genattrtab.c (gen_attr): Avoid NULL-deref after diagnosing
	absence of an define_enum call.

--
1.7.9.2.263.g9be8b7

Patch

diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index 4a4c2a2..bfbe3e8 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -1,6 +1,6 @@ 
 /* Generate code from machine description to compute values of attributes.
    Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012
    Free Software Foundation, Inc.
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)

@@ -2993,8 +2993,9 @@  gen_attr (rtx exp, int lineno)
       if (!et || !et->md_p)
 	error_with_line (lineno, "No define_enum called `%s' defined",
 			 attr->name);
-      for (ev = et->values; ev; ev = ev->next)
-	add_attr_value (attr, ev->name);
+      if (et)
+	for (ev = et->values; ev; ev = ev->next)
+	  add_attr_value (attr, ev->name);
     }
   else if (*XSTR (exp, 1) == '\0')
     attr->is_numeric = 1;