cccp.c (macroexpand): Avoid out of range accesses for omitted arguments.

* cccp.c (macroexpand): Avoid out of range accesses for omitted
	arguments.

From-SVN: r30289
This commit is contained in:
Jeffrey A Law 1999-10-31 07:54:56 +00:00 committed by Jeff Law
parent 0d9009fd94
commit f5d236de11
2 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Sun Oct 31 01:53:30 1999 Jeffrey A Law (law@cygnus.com)
* cccp.c (macroexpand): Avoid out of range accesses for omitted
arguments.
Sat Oct 30 22:42:50 1999 Stephen L Moshier <moshier@mediaone.net>
* c-lex.c (yylex): Accept 'f' in mantissa of hex float constant.

View File

@ -8581,7 +8581,12 @@ macroexpand (hp, op)
Also count number of times each arg is used. */
xbuf_len = defn->length;
for (ap = defn->pattern; ap != NULL; ap = ap->next) {
if (ap->stringify)
if (ap->stringify && args[ap->argno].stringified_length_bound == 0)
/* macarg is not called for omitted arguments, as a result
stringified_length_bound will be zero. We need to make
enough space for "". */
xbuf_len += 2;
else if (ap->stringify)
xbuf_len += args[ap->argno].stringified_length_bound;
else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional)
/* Add 4 for two newline-space markers to prevent