From: Tatsuo Ishii Date: Sat, 19 Jul 2025 06:48:37 +0000 (+0900) Subject: Fix resource leak while reading startup packet. X-Git-Tag: V4_5_8~9 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=3ef581f5c82a42c9713b811accc67575572a94c5;p=pgpool2.git Fix resource leak while reading startup packet. Per Coverity. Backpatch-through: v4.2 --- diff --git a/src/protocol/child.c b/src/protocol/child.c index 53a4cce68..5ccc1b074 100644 --- a/src/protocol/child.c +++ b/src/protocol/child.c @@ -778,8 +778,11 @@ read_startup_packet(POOL_CONNECTION * cp) } /* The database defaults to their user name. */ - if (sp->database == NULL || sp->database[0] == '\0') + if (sp->database == NULL) + sp->database = pstrdup(sp->user); + else if (sp->database[0] == '\0') { + pfree(sp->database); sp->database = pstrdup(sp->user); }