This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: cccp.c: Macro Argument Limitation


There were no objections to this, so I committed it.

Dave

Dave Brolley wrote:
> 
> Hi,
> 
> The field 'newlines' in the struct argdata in cccp.c is used to
> count the number of newlines spanned my a macro argument. That
> number is then used to compute the necessary size of the buffer
> to hold the argument. Currently, it is declared as 'char'. This
> means that it overflows at 127 lines if char is signed and 255
> otherwise. The buffer size is then subsequently miscalculated and
> bad things(tm) happen. Yes, this did come up in some real code.
> 
> The attached patch simply redeclares the field as 'int'.
> 
> OK to install?
> 
> The equivalent field in cpplib (cpphash.c) is always set to 0 and
> never updated, although it does get tested. Perhaps the field and
> the test should be removed? There is a comment that says "Fix me"
> beside the line where it is set.
> 
> Dave
> 
>   -----------------------------------------------------------------
> 2000-01-19  Dave Brolley  <brolley@cygnus.com>
> 
>         * cccp.c (argdata): Declare the 'newlines' field as 'int'.
> 
>   -----------------------------------------------------------------
> Index: cccp.c
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/cccp.c,v
> retrieving revision 1.94
> diff -c -p -r1.94 cccp.c
> *** cccp.c      2000/01/14 00:46:56     1.94
> --- cccp.c      2000/01/19 20:55:41
> *************** struct argdata {
> *** 8486,8492 ****
>     int stringified_length_bound;
>     U_CHAR *free1, *free2;
>     U_CHAR *free_ptr;
> !   char newlines;
>     char use_count;
>   };
> 
> --- 8486,8492 ----
>     int stringified_length_bound;
>     U_CHAR *free1, *free2;
>     U_CHAR *free_ptr;
> !   int newlines;
>     char use_count;
>   };
>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]