aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-07-27 11:10:38 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-07-27 11:10:38 -0400
commitdc4da3dc84c7c0d1a58275f78f0e3401385e3700 (patch)
treee81ff897285d51bcae5a90d8b9f9ebaad096c48e /src
parentefd7f8e36553cd32e445061cbbc80d32028f4248 (diff)
downloadpostgresql-dc4da3dc84c7c0d1a58275f78f0e3401385e3700.tar.gz
postgresql-dc4da3dc84c7c0d1a58275f78f0e3401385e3700.zip
Fix very minor memory leaks in psql's command.c.
\drds leaked its second pattern argument if any, and \connect leaked any empty-string or "-" arguments. These are old bugs, but it's hard to imagine any real use-case where the leaks could amount to anything meaningful, so not bothering with a back-patch. Daniel Gustafsson and Tom Lane Discussion: https://postgr.es/m/3641F19B-336A-431A-86CE-A80562505C5E@yesql.se
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/command.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 14c64208ca3..4e04459d45e 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -806,6 +806,9 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
pattern2 = psql_scan_slash_option(scan_state,
OT_NORMAL, NULL, true);
success = listDbRoleSettings(pattern, pattern2);
+
+ if (pattern2)
+ free(pattern2);
}
else
status = PSQL_CMD_UNKNOWN;
@@ -2725,6 +2728,8 @@ exec_command_slash_command_help(PsqlScanState scan_state, bool active_branch)
/*
* Read and interpret an argument to the \connect slash command.
+ *
+ * Returns a malloc'd string, or NULL if no/empty argument.
*/
static char *
read_connect_arg(PsqlScanState scan_state)
@@ -2750,7 +2755,10 @@ read_connect_arg(PsqlScanState scan_state)
return result;
if (*result == '\0' || strcmp(result, "-") == 0)
+ {
+ free(result);
return NULL;
+ }
return result;
}