diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-28 00:30:37 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-28 00:30:37 +0000 |
commit | a54130fbf4b98d104a2e662520592123bfbffa65 (patch) | |
tree | e9272d171d25a90ccbdb45733b655a0414aae29c /gcc/cppmacro.c | |
parent | 16b119892362ede5e971bb5fd08565a67fc5ad39 (diff) | |
download | gcc-a54130fbf4b98d104a2e662520592123bfbffa65.tar.gz |
2002-09-27 Alexander N. Kabaev <ak03@gte.com>
PR preprocessor/8055
* cppmacro.c (stringify_arg): Do not overflow the buffer
with the terminating NUL when the argument to be stringified
has no tokens.
* testsuite/gcc.dg/cpp/20020927-1.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@57599 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r-- | gcc/cppmacro.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index b8fb792de88..113b20dac24 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -409,6 +409,12 @@ stringify_arg (pfile, arg) } /* Commit the memory, including NUL, and return the token. */ + if ((size_t) (BUFF_LIMIT (pfile->u_buff) - dest) < 1) + { + size_t len_so_far = dest - BUFF_FRONT (pfile->u_buff); + _cpp_extend_buff (pfile, &pfile->u_buff, 1); + dest = BUFF_FRONT (pfile->u_buff) + len_so_far; + } len = dest - BUFF_FRONT (pfile->u_buff); BUFF_FRONT (pfile->u_buff) = dest + 1; return new_string_token (pfile, dest - len, len); |