psql: Fix memory leak with \gx used within a pipeline
authorMichael Paquier <[email protected]>
Tue, 4 Mar 2025 22:56:03 +0000 (07:56 +0900)
committerMichael Paquier <[email protected]>
Tue, 4 Mar 2025 22:56:03 +0000 (07:56 +0900)
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 <[email protected]>
Discussion: https://postgr.es/m/CAO6_XqqFVQjLjZQiL7xdwLpzZEy1ghO_JWvCFPM_OmwF9s7XdA@mail.gmail.com

src/bin/psql/command.c

index 0f27bf7a91f4d5fe491bfe8a65aaba84c70cadcd..fb0b27568c52de9ca7d89d06f3cb7fe7651b8073 100644 (file)
@@ -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;
        }