Patchwork [Fortran,committed] PR54462 - fix ICE on invalid

login
register
mail settings
Submitter Tobias Burnus
Date Sept. 5, 2012, 4:58 p.m.
Message ID <504784AF.1090900@net-b.de>
Download mbox | patch
Permalink /patch/181906/
State New
Headers show

Comments

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

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)