summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-03 21:07:19 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-03 21:07:19 +0000
commit69268d74e353e697ba4494589be3a50a5544aad4 (patch)
treeb47a5d4594631fea4f6b7a382efb4bab88cddbcd /libgfortran
parent0c7efac1ed999e50f423f2e3e401b9d9cbf2df29 (diff)
downloadgcc-69268d74e353e697ba4494589be3a50a5544aad4.tar.gz
PR libfortran/40330
Use heap memory for cached format strings. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148149 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/io/format.c13
2 files changed, 17 insertions, 2 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 2d27d0321bf..c1204932abe 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2009-06-04 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR libfortran/40330
+ * io/format.c (free_format_hash_table): Also free and nullify hash key.
+ (save_parsed_format): Copy string rather than pointer copy.
+
2009-05-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/40019
diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c
index a1ec43cfbb3..2c116d6fed4 100644
--- a/libgfortran/io/format.c
+++ b/libgfortran/io/format.c
@@ -87,7 +87,12 @@ free_format_hash_table (gfc_unit *u)
for (i = 0; i < FORMAT_HASH_SIZE; i++)
{
if (u->format_hash_table[i].hashed_fmt != NULL)
- free_format_data (u->format_hash_table[i].hashed_fmt);
+ {
+ free_format_data (u->format_hash_table[i].hashed_fmt);
+ free_mem (u->format_hash_table[i].key);
+ }
+ u->format_hash_table[i].key = NULL;
+ u->format_hash_table[i].key_len = 0;
u->format_hash_table[i].hashed_fmt = NULL;
}
}
@@ -164,7 +169,11 @@ save_parsed_format (st_parameter_dt *dtp)
free_format_data (u->format_hash_table[hash].hashed_fmt);
u->format_hash_table[hash].hashed_fmt = NULL;
- u->format_hash_table[hash].key = dtp->format;
+ if (u->format_hash_table[hash].key != NULL)
+ free_mem (u->format_hash_table[hash].key);
+ u->format_hash_table[hash].key = get_mem (dtp->format_len);
+ memcpy (u->format_hash_table[hash].key, dtp->format, dtp->format_len);
+
u->format_hash_table[hash].key_len = dtp->format_len;
u->format_hash_table[hash].hashed_fmt = dtp->u.p.fmt;
}