From 3b17de3424464875aabd5b37c055e11fb63bd6c9 Mon Sep 17 00:00:00 2001 From: Brad King <brad.king@kitware.com> Date: Thu, 8 Nov 2012 08:38:10 -0500 Subject: [PATCH] SystemInformation: Do not dereference NULL ifa_addr From "man getifaddrs": "This means ifa_addr and other fields can actually be NULL if the interface has no address..." Reported-by: Kornel Benko <kornel@lyx.org> Change-Id: I9d9ad3ae9fb50cbcab46fa8c06b270e4c56c288e --- SystemInformation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 6b63b94..6d990a9 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -1323,7 +1323,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( for (ifa=ifas; ifa!=NULL; ifa=ifa->ifa_next) { - int fam=ifa->ifa_addr->sa_family; + int fam = ifa->ifa_addr? ifa->ifa_addr->sa_family : -1; if ((fam==AF_INET) || (fam==AF_INET6)) { char host[NI_MAXHOST]={'\0'}; -- GitLab