changeset 1864:49e324e42081 draft

Fix a crash.
author Roy Marples <roy@marples.name>
date Tue, 19 Feb 2013 15:43:29 +0000
parents 0acca144defd
children efadc01f51dd
files dhcpcd.c
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/dhcpcd.c	Tue Feb 19 15:28:21 2013 +0000
+++ b/dhcpcd.c	Tue Feb 19 15:43:29 2013 +0000
@@ -73,7 +73,7 @@
 #define RELEASE_DELAY_S		0
 #define RELEASE_DELAY_NS	10000000
 
-struct if_head *ifaces;
+struct if_head *ifaces = NULL;
 char vendor[VENDORCLASSID_MAX_LEN];
 int pidfd = -1;
 struct if_options *if_options = NULL;
@@ -140,11 +140,13 @@
 
 	free_options(if_options);
 
-	while ((ifp = TAILQ_FIRST(ifaces))) {
-		TAILQ_REMOVE(ifaces, ifp, next);
-		free_interface(ifp);
+	if (ifaces) {
+		while ((ifp = TAILQ_FIRST(ifaces))) {
+			TAILQ_REMOVE(ifaces, ifp, next);
+			free_interface(ifp);
+		}
+		free(ifaces);
 	}
-	free(ifaces);
 
 	for (i = 0; i < ifac; i++)
 		free(ifav[i]);