diff mbox series

[mdnsd,04/10] interface: fix possible null pointer dereference

Message ID 20201013133621.27088-5-ynezz@true.cz
State Accepted
Delegated to: Petr Štetiar
Headers show
Series fixes and improvements | expand

Commit Message

Petr Štetiar Oct. 13, 2020, 1:36 p.m. UTC
Fixes following issue reported by clang-12 static analyzer:

 mdnsd/interface.c:250:6: warning: Access to field 'ipi_ifindex' results in a dereference of a null pointer (loaded from variable 'inp')
         if (inp->ipi_ifindex != iface->ifindex)
             ^~~~~~~~~~~~~~~~

 mdnsd/interface.c:323:6: warning: Access to field 'ipi6_ifindex' results in a dereference of a null pointer (loaded from variable 'inp')
         if (inp->ipi6_ifindex != iface->ifindex)
             ^~~~~~~~~~~~~~~~~

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 interface.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/interface.c b/interface.c
index 690e8579a44c..5fb9bad072ed 100644
--- a/interface.c
+++ b/interface.c
@@ -233,6 +233,9 @@  read_socket4(struct uloop_fd *u, unsigned int events)
 		}
 	}
 
+	if (!inp)
+		return;
+
 	if (debug > 1) {
 		char buf[256];
 
@@ -308,6 +311,9 @@  read_socket6(struct uloop_fd *u, unsigned int events)
 		}
 	}
 
+	if (!inp)
+		return;
+
 	if (debug > 1) {
 		char buf[256];