diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index f5ea75e223d..6e249e7d3b2 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -2390,10 +2390,12 @@ exec_command_restrict(PsqlScanState scan_state, bool active_branch, if (opt == NULL || opt[0] == '\0') { pg_log_error("\\%s: missing required argument", cmd); + free(opt); return PSQL_CMD_ERROR; } restrict_key = pstrdup(opt); + free(opt); restricted = true; } else @@ -2705,6 +2707,7 @@ exec_command_unrestrict(PsqlScanState scan_state, bool active_branch, if (opt == NULL || opt[0] == '\0') { pg_log_error("\\%s: missing required argument", cmd); + free(opt); return PSQL_CMD_ERROR; } @@ -2719,16 +2722,19 @@ exec_command_unrestrict(PsqlScanState scan_state, bool active_branch, if (!restricted) { pg_log_error("\\%s: not currently in restricted mode", cmd); + free(opt); return PSQL_CMD_ERROR; } else if (strcmp(opt, restrict_key) == 0) { pfree(restrict_key); restricted = false; + free(opt); } else { pg_log_error("\\%s: wrong key", cmd); + free(opt); return PSQL_CMD_ERROR; } }