Browse Source

Fix potential NULL dereference

Joseph C. Lehner 3 months ago
parent
commit
1545996501
1 changed files with 3 additions and 1 deletions
  1. 3 1
      ethsock.c

+ 3 - 1
ethsock.c

@@ -1325,6 +1325,8 @@ static int ethsock_ip_add_del(struct ethsock *sock, uint32_t ipaddr, uint32_t ip
 
 		(*undo)->ip[0] = ipaddr;
 		(*undo)->ip[1] = ipmask;
+	} else if (!add && (!undo || !*undo)) {
+		return 0;
 	}
 
 	ret = -1;
@@ -1445,7 +1447,7 @@ int ethsock_ip_add(struct ethsock *sock, uint32_t ipaddr, uint32_t ipmask, struc
 
 int ethsock_ip_del(struct ethsock *sock, struct ethsock_ip_undo **undo)
 {
-	if (!*undo) {
+	if (!undo || !*undo) {
 		return 0;
 	}