From 1545996501383bd6220071c35e59aca6cd3e9b9b Mon Sep 17 00:00:00 2001 From: "Joseph C. Lehner" Date: Thu, 11 Jan 2024 12:25:30 +0100 Subject: [PATCH] Fix potential NULL dereference --- ethsock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ethsock.c b/ethsock.c index 3f48e4c..763cf69 100644 --- a/ethsock.c +++ b/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; }