Silently handle freeaddrinfo(NULL) for compatibility with code which
works on other OSes. Also avoid unnecessary NULL check, free(NULL) is valid. Reviewed by: bjk (man page), hrs, hselasky, ume Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D12354
This commit is contained in:
parent
314e8196ea
commit
587e285e97
@ -18,7 +18,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd December 21, 2015
|
.Dd September 13, 2017
|
||||||
.Dt GETADDRINFO 3
|
.Dt GETADDRINFO 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -351,6 +351,17 @@ pointer should be a
|
|||||||
.Li addrinfo
|
.Li addrinfo
|
||||||
structure created by a call to
|
structure created by a call to
|
||||||
.Fn getaddrinfo .
|
.Fn getaddrinfo .
|
||||||
|
.Sh IMPLEMENTATION NOTES
|
||||||
|
The behavior of
|
||||||
|
.Li freeadrinfo(NULL)
|
||||||
|
is left unspecified by both
|
||||||
|
.St -susv4
|
||||||
|
and
|
||||||
|
.Dv "RFC 3493" .
|
||||||
|
The current implementation ignores a
|
||||||
|
.Dv NULL
|
||||||
|
argument for compatibility with programs that rely on the implementation
|
||||||
|
details of other operating systems.
|
||||||
.Sh RETURN VALUES
|
.Sh RETURN VALUES
|
||||||
.Fn getaddrinfo
|
.Fn getaddrinfo
|
||||||
returns zero on success or one of the error codes listed in
|
returns zero on success or one of the error codes listed in
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
* in the source code. This is because RFC2553 is silent about which error
|
* in the source code. This is because RFC2553 is silent about which error
|
||||||
* code must be returned for which situation.
|
* code must be returned for which situation.
|
||||||
* - freeaddrinfo(NULL). RFC2553 is silent about it. XNET 5.2 says it is
|
* - freeaddrinfo(NULL). RFC2553 is silent about it. XNET 5.2 says it is
|
||||||
* invalid. current code - SEGV on freeaddrinfo(NULL)
|
* invalid. Current code accepts NULL to be compatible with other OSes.
|
||||||
*
|
*
|
||||||
* Note:
|
* Note:
|
||||||
* - The code filters out AFs that are not supported by the kernel,
|
* - The code filters out AFs that are not supported by the kernel,
|
||||||
@ -359,14 +359,13 @@ freeaddrinfo(struct addrinfo *ai)
|
|||||||
{
|
{
|
||||||
struct addrinfo *next;
|
struct addrinfo *next;
|
||||||
|
|
||||||
do {
|
while (ai != NULL) {
|
||||||
next = ai->ai_next;
|
next = ai->ai_next;
|
||||||
if (ai->ai_canonname)
|
|
||||||
free(ai->ai_canonname);
|
free(ai->ai_canonname);
|
||||||
/* no need to free(ai->ai_addr) */
|
/* no need to free(ai->ai_addr) */
|
||||||
free(ai);
|
free(ai);
|
||||||
ai = next;
|
ai = next;
|
||||||
} while (ai);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user