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

login
register
mail settings
Submitter Steve Kargl
Date Feb. 15, 2011, 7:41 p.m.
Message ID <20110215194124.GA4716@troutmask.apl.washington.edu>
Download mbox | patch
Permalink /patch/83286/
State New
Headers show

Comments

Steve Kargl - Feb. 15, 2011, 7:41 p.m.
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.

Patch

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);
 }