Oh, sorry, it is incorrect, original code is already add 2 bytes for it.

Thanks.

On 11/16/2014 10:32 PM, Chen Gang wrote:
> When 'is_str' is true, need consider about 2 '"' for the extra space, or
> will cause memory overflow.
> 
> 2014-11-16  Chen Gang  <gang.chen.5...@gmail.com>
> 
>       * c-family/c-cppbuiltin.c (builtin_define_with_value): Add two
>       bytes for avoiding memory overflow issue.
> ---
>  gcc/c-family/c-cppbuiltin.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
> index 8e8cec4..cc3d90b 100644
> --- a/gcc/c-family/c-cppbuiltin.c
> +++ b/gcc/c-family/c-cppbuiltin.c
> @@ -1282,7 +1282,7 @@ builtin_define_with_value (const char *macro, const 
> char *expansion, int is_str)
>    char *buf;
>    size_t mlen = strlen (macro);
>    size_t elen = strlen (expansion);
> -  size_t extra = 2;  /* space for an = and a NUL */
> +  size_t extra = 4;  /* space for an =, a NUL, and 2 '"' when is_str is true 
> */
>  
>    if (is_str)
>      {
> 


-- 
Chen Gang

Open share and attitude like air water and life which God blessed

Reply via email to