correct memory leaks in namelist code for derived types
authorPaul Thomas <pault@gcc.gnu.org>
Mon, 18 Apr 2005 22:19:27 +0000 (22:19 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Mon, 18 Apr 2005 22:19:27 +0000 (22:19 +0000)
From-SVN: r98352

libgfortran/ChangeLog
libgfortran/io/list_read.c

index f4716af..d0dc7f1 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-18 Paul Thomas <pault@gcc.gnu.org>
+
+       * io/list_read.c (nml_touch_nodes, nml_read_obj,
+       nml_get_obj_data): Fix memory leaks in code for derived types.
+
 2005-04-11  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR libfortran/20950
 
 2005-04-17 Paul Thomas <pault@gcc.gnu.org>
 
-* io/list_read.c (eat_separator): at_eol = 1 replaced(zapped at some time?).
+       * io/list_read.c (eat_separator): at_eol = 1 replaced
+       (zapped at some time?).
 
 2005-04-17 Paul Thomas <pault@gcc.gnu.org>
 
-
        PR libgfortran/12884
        PR libgfortran/17285
        PR libgfortran/18122
index becf09e..bc592dd 100644 (file)
@@ -1673,6 +1673,7 @@ nml_touch_nodes (namelist_info * nl)
       else
        break;
     }
+  free_mem (ext_name);
   return;
 }
 
@@ -1914,10 +1915,16 @@ nml_read_obj (namelist_info * nl, index_type offset)
              {
 
                if (nml_read_obj (cmp, (index_type)(pdata - nl->mem_pos)) == FAILURE)
-                 return FAILURE;
+                 {
+                   free_mem (obj_name);
+                   return FAILURE;
+                 }
 
                if (input_complete)
-                 return SUCCESS;
+                 {
+                   free_mem (obj_name);
+                   return SUCCESS;
+                 }
              }
 
            free_mem (obj_name);
@@ -2105,6 +2112,7 @@ get_name:
       strcpy (ext_name, root_nl->var_name);
       strcat (ext_name, saved_string);
       nl = find_nml_node (ext_name);
+      free_mem (ext_name);
     }
   else
     nl = find_nml_node (saved_string);