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

Re: gEDA: Ancient bug found



Hi Martin,


>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... :)
>

	I knew the moment I typed send, somebody was going to point
that out.  :-)	Yes it should be as you said.  I believe that one of my
open bugs somewhere addresses this (check all mallocs), but I'll make
the appropriate correction here.  Doing a quick grep showed that some
of my mallocs are okay, but there are a few bad ones.

								-Ales

(I think that on most machine sizeof(char)=1, but there's absolutely
 no guarantee of that; or is there?)