]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
symbol.c (gfc_undo_symbols): Correctly undo namelists.
authorMikael Morin <mikael@gcc.gnu.org>
Sun, 16 Sep 2012 11:26:52 +0000 (11:26 +0000)
committerMikael Morin <mikael@gcc.gnu.org>
Sun, 16 Sep 2012 11:26:52 +0000 (11:26 +0000)
fortran/
* symbol.c (gfc_undo_symbols): Correctly undo namelists.

testsuite/
* gfortran.dg/namelist_75.f90: New test.

From-SVN: r191357

gcc/fortran/ChangeLog
gcc/fortran/symbol.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/namelist_75.f90 [new file with mode: 0644]

index 6259229a25e084ea6c6b62e0608f62690ec60a5c..f363d59a7503c2cf2a8283832eb71f6afad41ea8 100644 (file)
@@ -1,3 +1,7 @@
+2012-09-16  Mikael Morin  <mikael@gcc.gnu.org>
+
+       * symbol.c (gfc_undo_symbols): Correctly undo namelists.
+
 2012-09-15  Tobias Burnus  <burnus@net-b.de>
 
        * trans-io.c (gfc_trans_transfer): Add an assert.
index d68208d3010e9ec2ff7cedf91f585f1d7cf04a28..c914e65cac208b3614affd4f349f001ec4a2ec34 100644 (file)
@@ -2996,7 +2996,7 @@ gfc_undo_symbols (void)
        {
          if (p->namelist_tail != old->namelist_tail)
            {
-             gfc_free_namelist (old->namelist_tail);
+             gfc_free_namelist (old->namelist_tail->next);
              old->namelist_tail->next = NULL;
            }
        }
index 6ae64584dc41e9351bfbfc6243eeb3249a378d85..b6f1990beb88c35602b0c5128b86b4aa91134c36 100644 (file)
@@ -1,3 +1,7 @@
+2012-09-16  Mikael Morin  <mikael@gcc.gnu.org>
+
+       * gfortran.dg/namelist_75.f90: New test.
+
 2012-09-15  Tom de Vries  <tom@codesourcery.com>
 
        * gcc.dg/tree-ssa/vrp82.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/namelist_75.f90 b/gcc/testsuite/gfortran.dg/namelist_75.f90
new file mode 100644 (file)
index 0000000..c88da65
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do compile }
+!
+! Tests a write-after-free memory error fix in gfc_undo_symbols
+
+program test_nml
+
+  namelist /foo/ bar, baz
+  namelist /foo/ wrong, ,  ! { dg-error "Syntax error in NAMELIST" }
+
+end program test_nml