From 5b2da1a2ecdb4cc34428426f1e6c4266ce709a86 Mon Sep 17 00:00:00 2001
From: Sergey Tatarintsev <s.tatarintsev@postgrespro.ru>
Date: Mon, 10 Nov 2025 11:41:12 +0700
Subject: [PATCH v1] Ability to pass NULL as a hintp to pg_getaddrinfo_all()

---
 src/common/ip.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/common/ip.c b/src/common/ip.c
index 0e7897a5c8f..e78a7439a01 100644
--- a/src/common/ip.c
+++ b/src/common/ip.c
@@ -58,7 +58,8 @@ pg_getaddrinfo_all(const char *hostname, const char *servname,
 	/* not all versions of getaddrinfo() zero *result on failure */
 	*result = NULL;
 
-	if (hintp->ai_family == AF_UNIX)
+	/* Pass NULL to hintp is equivalent to ai_family=AF_UNSPEC */
+	if (hintp && hintp->ai_family == AF_UNIX)
 		return getaddrinfo_unix(servname, hintp, result);
 
 	/* NULL has special meaning to getaddrinfo(). */
-- 
2.43.0

