format.c (parse_format): Set limit on size of format strings that will be cached.
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 15 Jan 2010 15:52:28 +0000 (15:52 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 15 Jan 2010 15:52:28 +0000 (15:52 +0000)
2010-01-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

* io/format.c (parse_format): Set limit on size of format strings that
will be cached.

From-SVN: r155939

libgfortran/ChangeLog
libgfortran/io/format.c

index fbd9dd43309165a1a6260eb5c8b49d7132247e65..0b24143c2b9fee071fc075a95b432a08f695201f 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       * io/format.c (parse_format): Set limit on size of format strings that
+       will be cached.
+
 2010-01-05  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * configure: Regenerate.
index cafea8732e46367d83e2011c063ade38bcbb3d04..13516d2f8a6b7aabd87c81b0c989944459e156fe 100644 (file)
@@ -1212,13 +1212,18 @@ revert (st_parameter_dt *dtp)
 
 /* parse_format()-- Parse a format string.  */
 
+#define FORMAT_CACHE_STRING_LIMIT 256
+
 void
 parse_format (st_parameter_dt *dtp)
 {
   format_data *fmt;
   bool format_cache_ok;
 
-  format_cache_ok = !is_internal_unit (dtp);
+  /* Don't cache for internal units and set an arbitrary limit on the size of
+     format strings we will cache.  (Avoids memory issues.)  */
+  format_cache_ok = !is_internal_unit (dtp)
+                   && (dtp->format_len < FORMAT_CACHE_STRING_LIMIT );
 
   /* Lookup format string to see if it has already been parsed.  */
   if (format_cache_ok)