[Fortran,committed] PR54462 - fix ICE on invalid

Submitted by Tobias Burnus on Sept. 5, 2012, 4:58 p.m.

Details

Message ID 504784AF.1090900@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Sept. 5, 2012, 4:58 p.m.
Rather obvious fix. gfc_undo_symbols segfaulted when the COMMON 
statement aborted before the common symtree was created. Committed as 
Rev. 190989.

Hopefully, that's the last fall out of my memory clean up patch.

The hopefully last issue with the current FINAL patch has already been 
fixed by Mikael. Thanks!

Tobias

Patch hide | download patch | download mbox

Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(Revision 190985)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@ 
+2012-09-04  Tobias Burnus  <burnus@net-b.de>
+
+	PR fortran/54462
+	* symbol.c (gfc_undo_symbols): Avoid NULL pointer dereference.
+
 2012-09-04  Janus Weil  <janus@gcc.gnu.org>
 
 	PR fortran/54435
Index: gcc/fortran/symbol.c
===================================================================
--- gcc/fortran/symbol.c	(Revision 190985)
+++ gcc/fortran/symbol.c	(Arbeitskopie)
@@ -2919,10 +2919,12 @@  gfc_undo_symbols (void)
 		  gfc_symtree st, *st0;
 		  st0 = find_common_symtree (p->ns->common_root,
 					     p->common_block);
-
-		  st.name = st0->name;
-		  gfc_delete_bbt (&p->ns->common_root, &st, compare_symtree);
-		  free (st0);
+		  if (st0)
+		    {
+		      st.name = st0->name;
+		      gfc_delete_bbt (&p->ns->common_root, &st, compare_symtree);
+		      free (st0);
+		    }
 		}
 
 	      if (p->common_block->head == p)