From: Michael Paquier Date: Tue, 4 Mar 2025 22:56:03 +0000 (+0900) Subject: psql: Fix memory leak with \gx used within a pipeline X-Git-Tag: REL_18_BETA1~688 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=54d23601b978d2552696fb7fe35ae5d6102ea2cb;p=postgresql.git psql: Fix memory leak with \gx used within a pipeline While inside a pipeline, \gx is currently forbidden and will make exec_command_g() exit early. There was a memory leak in this code path, so let's fix it. Author: Anthonin Bonnefoy Discussion: https://postgr.es/m/CAO6_XqqFVQjLjZQiL7xdwLpzZEy1ghO_JWvCFPM_OmwF9s7XdA@mail.gmail.com --- diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 0f27bf7a91f..fb0b27568c5 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1739,6 +1739,7 @@ exec_command_g(PsqlScanState scan_state, bool active_branch, const char *cmd) { pg_log_error("\\gx not allowed in pipeline mode"); clean_extended_state(); + free(fname); return PSQL_CMD_ERROR; }