getifaddrs.3: Prevent possible NULL pointer access in example program

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Thomas Jarosch 2010-10-06 07:34:09 +02:00 committed by Michael Kerrisk
parent 9d7a9f90c7
commit ebd05fecfe
1 changed files with 4 additions and 1 deletions

View File

@ -30,7 +30,7 @@
.\" for glibc specificities, provide an example.
.\" 2009-01-14 mtk, many edits and changes, rewrote example program.
.\"
.TH GETIFADDRS 3 2009-01-23 "GNU" "Linux Programmer's Manual"
.TH GETIFADDRS 3 2010-10-06 "GNU" "Linux Programmer's Manual"
.SH NAME
getifaddrs, freeifaddrs \- get interface addresses
.SH SYNOPSIS
@ -245,6 +245,9 @@ main(int argc, char *argv[])
can free list later */
for (ifa = ifaddr; ifa != NULL; ifa = ifa\->ifa_next) {
if (ifa\->ifa_addr == NULL)
continue;
family = ifa\->ifa_addr\->sa_family;
/* Display interface name and family (including symbolic