On Mon, May 19, 2014 at 07:52:05AM +0200, Lukas Slebodnik wrote:
> On (18/05/14 04:58), Jakub Hrozek wrote:
> >On Sat, 2014-05-17 at 19:38 +0200, Lukas Slebodnik wrote:
> >> ehlo,
> >> We should call freeaddrinfo only in situation if getaddrinfo succeeds.
> >> It is not specified in RFC2553 the behaviour of calling freeaddrinfo
> >> with the NULL argument. It is more portable to do not rely on undocumented
> >> behaviour of glibc.
> >> http://www.ietf.org/rfc/rfc2553.txt
> >> simple patch is attached.
> >> LS
> >While the behaviour with the NULL argument is not explicitly spelled
> >out, I don't see the RFC saying that the behaviour is undefined either.
> >Is there really any platform where a free* function would not be a noop?
> POSIX functions don't require you to zero the pointers used for output unless
> specified otherwise.
> From :
> Upon successful return of getaddrinfo(), the location to which res points
> shall refer to a linked list of addrinfo structures, each of which shall
> specify a socket address and information for use in creating a socket with
> which to use that socket address.
> It's pretty clear that the standard is written with an assumption that in
> other cases, the res variable is not being touched. In other way. it does not
> make a sense to call freeaddrinfo, if getaddrinfo fails.
> The one of possible implementation where calling freeaddrinfo(NULL) will crash.
>  http://pubs.opengroup.org/onlinepubs/9699919799/functions/freeaddrinfo.html
OK, thanks. Then I think your patch makes sense.