[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: freeaddrinfo doesn't check for NULL
Why should it?
Your diff makes it OK for NULL to be passed to it, and then if you port
your code to another system, the crash shows up there.
Instead, quite frankly, I *prefer* if code that does things wrong crashes,
so that the bug can get fixed.
This is ridiculous. Where does it say that freeaddrinfo should ignore
NULL pointers?
> /usr/src/lib/libc/net/freeaddrinfo.c doesn't check if its arg is NULL.
>
> Thanks,
> Alf
>
> --- lib/libc/net/freeaddrinfo.c.orig Mon Mar 15 09:27:25 2004
> +++ lib/libc/net/freeaddrinfo.c Mon Mar 15 09:16:31 2004
> @@ -39,11 +39,11 @@
> {
> struct addrinfo *p;
>
> - do {
> + while(ai) {
> p = ai;
> ai = ai->ai_next;
> if (p->ai_canonname)
> free(p->ai_canonname);
> free((void *)p);
> - } while (ai);
> + };
> }