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
This commit is contained in:
Tobias Burnus 2013-10-01 22:52:49 +02:00 committed by Tobias Burnus
parent f55d4a2074
commit 7902928918
2 changed files with 35 additions and 4 deletions

View File

@ -1,3 +1,10 @@
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.
2013-09-20 Alan Modra <amodra@gmail.com>
* configure: Regenerate.

View File

@ -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