diff --git a/src/openvpn/socket_util.h b/src/openvpn/socket_util.h
index e85f6fe..a7821df 100644
--- a/src/openvpn/socket_util.h
+++ b/src/openvpn/socket_util.h
@@ -294,6 +294,10 @@
 static inline bool
 addr_match(const struct openvpn_sockaddr *a1, const struct openvpn_sockaddr *a2)
 {
+    if (a1->addr.sa.sa_family != a2->addr.sa.sa_family)
+    {
+        return false;
+    }
     switch (a1->addr.sa.sa_family)
     {
         case AF_INET:
@@ -381,6 +385,10 @@
 static inline bool
 addr_port_match(const struct openvpn_sockaddr *a1, const struct openvpn_sockaddr *a2)
 {
+    if (a1->addr.sa.sa_family != a2->addr.sa.sa_family)
+    {
+        return false;
+    }
     switch (a1->addr.sa.sa_family)
     {
         case AF_INET:
