From c2f65e027996622ad299a61b783c2cd6377f2ed2 Mon Sep 17 00:00:00 2001 From: Maxim Orlov Date: Fri, 6 Dec 2024 18:46:09 +0300 Subject: [PATCH v3] Use pstrdup for remote_host and remote_port save in port structure --- src/backend/postmaster/postmaster.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 110d05d13e..be31d01760 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -4342,8 +4342,8 @@ BackendInitialize(Port *port) * Save remote_host and remote_port in port structure (after this, they * will appear in log_line_prefix data for log messages). */ - port->remote_host = strdup(remote_host); - port->remote_port = strdup(remote_port); + port->remote_host = MemoryContextStrdup(TopMemoryContext, remote_host); + port->remote_port = MemoryContextStrdup(TopMemoryContext, remote_port); /* And now we can issue the Log_connections message, if wanted */ if (Log_connections) @@ -4374,7 +4374,9 @@ BackendInitialize(Port *port) ret == 0 && strspn(remote_host, "0123456789.") < strlen(remote_host) && strspn(remote_host, "0123456789ABCDEFabcdef:") < strlen(remote_host)) - port->remote_hostname = strdup(remote_host); + { + port->remote_hostname = MemoryContextStrdup(TopMemoryContext, remote_host); + } /* * Ready to begin client interaction. We will give up and _exit(1) after -- 2.47.0