diff options
author | Tobias Burnus <burnus@net-b.de> | 2013-03-29 10:37:37 +0100 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2013-03-29 10:37:37 +0100 |
commit | d80b9b477774b0e783f943cd86334ca64b9a477b (patch) | |
tree | 4927153fd52d2d17a343896d19bad4246aa38bdc /libgfortran/io/format.c | |
parent | a0b012be6aef65bd11107f8dac814c3ac36f95d0 (diff) | |
download | gcc-d80b9b477774b0e783f943cd86334ca64b9a477b.zip gcc-d80b9b477774b0e783f943cd86334ca64b9a477b.tar.gz gcc-d80b9b477774b0e783f943cd86334ca64b9a477b.tar.bz2 |
re PR libfortran/56737 (Wrong I/O result with format cache for Hollerith strings)
2013-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* io/format.c (parse_format): With caching, copy
dtp->format string.
(save_parsed_format): Use dtp->format directy without
copying.
2013-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* testsuite/gfortran.dg/fmt_cache_3.f90: New.
(Plus: Move fortran/ChangeLog item to libgfortran/ChangeLog)
From-SVN: r197229
Diffstat (limited to 'libgfortran/io/format.c')
-rw-r--r-- | libgfortran/io/format.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index c64596b..db95e49 100644 --- a/libgfortran/io/format.c +++ b/libgfortran/io/format.c @@ -148,8 +148,7 @@ save_parsed_format (st_parameter_dt *dtp) u->format_hash_table[hash].hashed_fmt = NULL; free (u->format_hash_table[hash].key); - u->format_hash_table[hash].key = xmalloc (dtp->format_len); - memcpy (u->format_hash_table[hash].key, dtp->format, dtp->format_len); + u->format_hash_table[hash].key = dtp->format; u->format_hash_table[hash].key_len = dtp->format_len; u->format_hash_table[hash].hashed_fmt = dtp->u.p.fmt; @@ -1223,6 +1222,13 @@ parse_format (st_parameter_dt *dtp) /* Not found so proceed as follows. */ + if (format_cache_ok) + { + char *fmt_string = xmalloc (dtp->format_len); + memcpy (fmt_string, dtp->format, dtp->format_len); + dtp->format = fmt_string; + } + dtp->u.p.fmt = fmt = xmalloc (sizeof (format_data)); fmt->format_string = dtp->format; fmt->format_string_len = dtp->format_len; @@ -1257,6 +1263,8 @@ parse_format (st_parameter_dt *dtp) if (fmt->error) { format_error (dtp, NULL, fmt->error); + if (format_cache_ok) + free (dtp->format); free_format_hash_table (dtp->u.p.current_unit); return; } |