Le dimanche 12 avril 2015, 15:10:14 oldfaber a écrit :
> > Except that later there is "name = buf;" with name staying live out of
> > this if scope. So this change is not correct. It would be better to move
> > it out up a bit.
> > 
> > Best regards,
> > 
> > Thomas
> 
> Yes, you are right, the patch is wrong.
> 
> What about removing char buf[32] and replacing
>                 strcpy(buf, "__bound_");
>                 strcat(buf, name);
>                 name = buf;
> 
> with
> 
>                 if (strlen(name) + strlen("__bound_") <
> (unsigned)STRING_MAX_SIZE) {
>                     memmove(name + strlen("__bound_"), name, strlen(name));
>                     memcpy(name, "__bound_", strlen("__bound_"));
>                 }

Oh my, get_tok_str returns a pointer to a local variable. So the proper fix 
would be to make get_tok_str take a CString as parameter and have the caller 
allocate the buffer associated with the CString. And then it's just a matter of 
allocating buf to STRING_MAX_SIZE.

Cheers,

Thomas

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to