[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gEDA: Ancient bug found





On Sat, 4 Nov 2000, Ales Hvezda wrote:

> In libgeda/src/u_basic.c search for (around line 101):
> 
>         /* this is going to be extra large, but it's only for temp usage */
>         /* anyway */
>         return_value = malloc(sizeof(char)*strlen(string));
> 
> For the unbiased viewer there is something missing here, mainly space
> for the null character, so make this line:
> 
>         return_value = malloc(sizeof(char)*strlen(string)+1);
> 

Thanks Ales,

but shouldn't it be rather:

return_value = malloc(sizeof(char)*(strlen(string)+1));

One one hand you are assuming that sizeof(char)=1 (is that guaranteed to
be the case?), on the other hand you don't... :)

Martin