Fix resource leak in hearbeat receiver process.
authorTatsuo Ishii <ishii@postgresql.org>
Sat, 14 Jun 2025 07:15:59 +0000 (16:15 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Sat, 14 Jun 2025 07:15:59 +0000 (16:15 +0900)
Pointed out by Coverity.
Backpatch-through: v4.6

src/watchdog/wd_heartbeat.c

index 561cdfccf2d4c13046810136184920764da17f85..28a01d290d9e5d15e169660b1f6fd3a53aa084d6 100644 (file)
@@ -357,6 +357,7 @@ wd_create_hb_recv_socket(WdHbIf * hb_if)
                                        ereport(LOG,
                                                        (errmsg("failed to create watchdog heartbeat receive socket."),
                                                         errdetail("setsockopt(SO_BINDTODEVICE) requires root privilege")));
+                                       close(sock);
                                        continue;
                                }
                        }
@@ -364,6 +365,7 @@ wd_create_hb_recv_socket(WdHbIf * hb_if)
                        ereport(LOG,
                                        (errmsg("failed to create watchdog heartbeat receive socket"),
                                         errdetail("setsockopt(SO_BINDTODEVICE) is not available on this platform")));
+                       close(sock);
                        continue;
 #endif
                }