aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppmacro.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2002-09-28 00:30:37 +0000
committerZack Weinberg <zack@gcc.gnu.org>2002-09-28 00:30:37 +0000
commit57147be1b61543b6ae26836c03f7138e3121ecfe (patch)
treee9272d171d25a90ccbdb45733b655a0414aae29c /gcc/cppmacro.c
parentb1af5a30a54316b085b979805a6bced0ff93a7b1 (diff)
downloadgcc-57147be1b61543b6ae26836c03f7138e3121ecfe.zip
gcc-57147be1b61543b6ae26836c03f7138e3121ecfe.tar.gz
gcc-57147be1b61543b6ae26836c03f7138e3121ecfe.tar.bz2
re PR preprocessor/8055 (PATCH: cpp0 dies with SIG11 when building FreeBSD kernel)
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. From-SVN: r57599
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r--gcc/cppmacro.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c
index b8fb792..113b20d 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);