\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
pattern2 = psql_scan_slash_option(scan_state,
OT_NORMAL, NULL, true);
success = listDbRoleSettings(pattern, pattern2);
+
+ if (pattern2)
+ free(pattern2);
}
else
status = PSQL_CMD_UNKNOWN;
/*
* 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)
return result;
if (*result == '\0' || strcmp(result, "-") == 0)
+ {
+ free(result);
return NULL;
+ }
return result;
}