diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2001-03-27 21:04:55 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2001-03-27 21:04:55 +0000 |
commit | b044e9d5e9f15c20a62ba92c601128e9630438f4 (patch) | |
tree | 81ff1a7c3049b496cb655b24c7fae84130f0a4bb /gcc | |
parent | 0b29309adf64a5545445c15b772eae3a615df81f (diff) | |
download | gcc-b044e9d5e9f15c20a62ba92c601128e9630438f4.zip gcc-b044e9d5e9f15c20a62ba92c601128e9630438f4.tar.gz gcc-b044e9d5e9f15c20a62ba92c601128e9630438f4.tar.bz2 |
* cppmacro.c (stringify_arg): Null terminate strings.
From-SVN: r40880
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cppmacro.c | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 19c4205..0ff9729 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index 7d20f1c..6246980 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -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; |