aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2013-10-01 22:52:49 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2013-10-01 22:52:49 +0200
commit7902928918b076991f98ba43678cc287abb5f316 (patch)
tree4f75142ff42c8055827745787348940a93985d35 /libgfortran/io
parentf55d4a20747f0a2f6d721e0f19340607f7bb06dc (diff)
downloadgcc-7902928918b076991f98ba43678cc287abb5f316.zip
gcc-7902928918b076991f98ba43678cc287abb5f316.tar.gz
gcc-7902928918b076991f98ba43678cc287abb5f316.tar.bz2
re PR fortran/55469 (memory leak on read with istat.ne.0)
2013-10-01 Tobias Burnus <burnus@net-b.de> PR fortran/55469 * io/list_read (parse_repeat, read_integer, read_character, parse_real, read_real, check_type, list_formatted_read_scalar, finish_list_read): Call list_free. From-SVN: r203086
Diffstat (limited to 'libgfortran/io')
-rw-r--r--libgfortran/io/list_read.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 82a98a5..d38a4a8 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -615,6 +615,7 @@ parse_repeat (st_parameter_dt *dtp)
free_saved (dtp);
if (c == EOF)
{
+ free_line (dtp);
hit_eof (dtp);
return 1;
}
@@ -904,11 +905,14 @@ read_integer (st_parameter_dt *dtp, int length)
free_saved (dtp);
if (c == EOF)
{
+ free_line (dtp);
hit_eof (dtp);
return;
}
else if (c != '\n')
eat_line (dtp);
+
+ free_line (dtp);
snprintf (message, MSGLEN, "Bad integer for item %d in list input",
dtp->u.p.item_count);
generate_error (&dtp->common, LIBERROR_READ_VALUE, message);
@@ -1078,7 +1082,6 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused)))
unget_char (dtp, c);
eat_separator (dtp);
dtp->u.p.saved_type = BT_CHARACTER;
- free_line (dtp);
}
else
{
@@ -1087,10 +1090,12 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused)))
dtp->u.p.item_count);
generate_error (&dtp->common, LIBERROR_READ_VALUE, message);
}
+ free_line (dtp);
return;
eof:
free_saved (dtp);
+ free_line (dtp);
hit_eof (dtp);
}
@@ -1285,11 +1290,14 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length)
free_saved (dtp);
if (c == EOF)
{
+ free_line (dtp);
hit_eof (dtp);
return 1;
}
else if (c != '\n')
eat_line (dtp);
+
+ free_line (dtp);
snprintf (message, MSGLEN, "Bad floating point number for item %d",
dtp->u.p.item_count);
generate_error (&dtp->common, LIBERROR_READ_VALUE, message);
@@ -1390,11 +1398,14 @@ eol_4:
free_saved (dtp);
if (c == EOF)
{
+ free_line (dtp);
hit_eof (dtp);
return;
}
else if (c != '\n')
eat_line (dtp);
+
+ free_line (dtp);
snprintf (message, MSGLEN, "Bad complex value in item %d of list input",
dtp->u.p.item_count);
generate_error (&dtp->common, LIBERROR_READ_VALUE, message);
@@ -1629,7 +1640,10 @@ read_real (st_parameter_dt *dtp, void * dest, int length)
eat_separator (dtp);
push_char (dtp, '\0');
if (convert_real (dtp, dest, dtp->u.p.saved_string, length))
- return;
+ {
+ free_saved (dtp);
+ return;
+ }
free_saved (dtp);
dtp->u.p.saved_type = BT_REAL;
@@ -1767,12 +1781,14 @@ read_real (st_parameter_dt *dtp, void * dest, int length)
free_saved (dtp);
if (c == EOF)
{
+ free_line (dtp);
hit_eof (dtp);
return;
}
else if (c != '\n')
eat_line (dtp);
+ free_line (dtp);
snprintf (message, MSGLEN, "Bad real number in item %d of list input",
dtp->u.p.item_count);
generate_error (&dtp->common, LIBERROR_READ_VALUE, message);
@@ -1789,6 +1805,7 @@ check_type (st_parameter_dt *dtp, bt type, int kind)
if (dtp->u.p.saved_type != BT_UNKNOWN && dtp->u.p.saved_type != type)
{
+ free_line (dtp);
snprintf (message, MSGLEN, "Read type %s where %s was expected for item %d",
type_name (dtp->u.p.saved_type), type_name (type),
dtp->u.p.item_count);
@@ -1803,6 +1820,7 @@ check_type (st_parameter_dt *dtp, bt type, int kind)
if ((type != BT_COMPLEX && dtp->u.p.saved_length != kind)
|| (type == BT_COMPLEX && dtp->u.p.saved_length != kind*2))
{
+ free_line (dtp);
snprintf (message, MSGLEN,
"Read kind %d %s where kind %d is required for item %d",
type == BT_COMPLEX ? dtp->u.p.saved_length / 2
@@ -1978,7 +1996,10 @@ list_formatted_read_scalar (st_parameter_dt *dtp, bt type, void *p,
cleanup:
if (err == LIBERROR_END)
- hit_eof (dtp);
+ {
+ free_line (dtp);
+ hit_eof (dtp);
+ }
return err;
}
@@ -2026,7 +2047,10 @@ finish_list_read (st_parameter_dt *dtp)
err = eat_line (dtp);
if (err == LIBERROR_END)
- hit_eof (dtp);
+ {
+ free_line (dtp);
+ hit_eof (dtp);
+ }
}
/* NAMELIST INPUT