[Committed] PR fortran/47633 -- fix off-by-one.

Steve Kargl sgk@troutmask.apl.washington.edu
Tue Feb 15 19:41:00 GMT 2011


Tobias has reviewed and OK the patch in the PR audit trail.

For the record, here is the diff.

2011-02-15  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/47633
	. simplify.c (gfc_simplify_compiler_version): Fix off-by-one issue.

Index: simplify.c
===================================================================
--- simplify.c	(revision 170194)
+++ simplify.c	(working copy)
@@ -6844,9 +6844,9 @@ gfc_simplify_compiler_version (void)
   char *buffer;
   size_t len;
 
-  len = strlen ("GCC version ") + strlen (version_string) + 1;
-  buffer = (char*) alloca (len);
-  snprintf (buffer, len, "GCC version %s", version_string);
+  len = strlen ("GCC version ") + strlen (version_string);
+  buffer = XALLOCAVEC (char, len + 1);
+  snprintf (buffer, len + 1, "GCC version %s", version_string);
   return gfc_get_character_expr (gfc_default_character_kind,
                                 &gfc_current_locus, buffer, len);
 }

-- 
Steve



More information about the Fortran mailing list