* cppmacro.c (stringify_arg): Null terminate strings.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Tue, 27 Mar 2001 21:04:55 +0000 (21:04 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Tue, 27 Mar 2001 21:04:55 +0000 (21:04 +0000)
From-SVN: r40880

gcc/ChangeLog
gcc/cppmacro.c

index 19c4205afdd5dda9573cb46484b21179d109cc22..0ff97291e32fd3dbd14197f66274163fc94b4d7e 100644 (file)
@@ -1,3 +1,7 @@
+2001-03-27  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * cppmacro.c (stringify_arg): Null terminate strings.
+
 2001-03-27  Zack Weinberg  <zackw@stanford.edu>
 
        * config.gcc (m68hc11-*-*, m68hc12-*-*): Convert to new tm.h
index 7d20f1c0464c76f6ed4d20488100be666dba4bfa..62469804f4a7022e0c42516d4963f9fdfa87dda7 100644 (file)
@@ -296,7 +296,7 @@ stringify_arg (pfile, arg)
       if (escape_it)
        /* Worst case is each char is octal.  */
        len *= 4;
-      len++;                   /* Room for initial space.  */
+      len += 2;                        /* Room for initial space and final NUL.  */
 
       dest = &start[total_len];
       if (dest + len > POOL_LIMIT (pool))
@@ -334,7 +334,9 @@ stringify_arg (pfile, arg)
       total_len--;
     }
 
-  POOL_COMMIT (pool, total_len);
+  /* Null terminate, and commit the memory.  */
+  start[total_len] = '\0';
+  POOL_COMMIT (pool, total_len + 1);
 
   arg->stringified = xnew (cpp_token);
   arg->stringified->flags = 0;