From 5827e84d88c0216c9e9e2373378b6992ce8357c5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 02:23:29 +0100 Subject: libreplace: fix rep_freeifaddrs to not segfault on NULL input. Michael (cherry picked from commit 0cbb87453beb52c6b0bc3a48791f49678f4030c5) (This used to be commit 34d906ef44d1a5c3452097a9cac438d721fe35c1) --- source3/lib/replace/getifaddrs.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index adc2517e5c..f6f0ec080c 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -44,13 +44,14 @@ void rep_freeifaddrs(struct ifaddrs *ifp) { - free(ifp->ifa_name); - free(ifp->ifa_addr); - free(ifp->ifa_netmask); - free(ifp->ifa_dstaddr); - if (ifp->ifa_next != NULL) + if (ifp != NULL) { + free(ifp->ifa_name); + free(ifp->ifa_addr); + free(ifp->ifa_netmask); + free(ifp->ifa_dstaddr); freeifaddrs(ifp->ifa_next); - free(ifp); + free(ifp); + } } static struct sockaddr *sockaddr_dup(struct sockaddr *sa) -- cgit