Fix to check the return value of malloc(). master
authorTatsuo Ishii <ishii@postgresql.org>
Wed, 7 Jan 2026 11:31:31 +0000 (20:31 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Wed, 7 Jan 2026 11:31:31 +0000 (20:31 +0900)
create_inet_domain_sockets() forgot to check the return value of
malloc() while allocating memory for socket fds.

Backpatch-through: v4.3

src/main/pgpool_main.c

index 5e7832a8824649b85e9c8fab0d0964a1517b08c5..98fba4b2bbef719708eca230816646b5f7590136 100644 (file)
@@ -982,6 +982,9 @@ create_inet_domain_sockets(const char *hostname, const int port)
                n++;
 
        sockfds = malloc(sizeof(int) * (n + 1));
+       if (sockfds == NULL)
+               ereport(FATAL,
+                               (errmsg("failed to allocate memory for socket fds")));
        n = 0;
        for (walk = res; walk != NULL; walk = walk->ai_next)
                sockfds[n++] = -1;