mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Code + docs review for escaping of option values (commit 11a020eb6
).
Avoid memory leak from incorrect choice of how to free a StringInfo (resetStringInfo doesn't do it). Now that pg_split_opts doesn't scribble on the optstr, mark that as "const" for clarity. Attach the commentary in protocol.sgml to the right place, and add documentation about the user-visible effects of this change on postgres' -o option and libpq's PGOPTIONS option.
This commit is contained in:
@ -418,7 +418,7 @@ InitCommunication(void)
|
||||
* backslashes, with \\ representing a literal backslash.
|
||||
*/
|
||||
void
|
||||
pg_split_opts(char **argv, int *argcp, char *optstr)
|
||||
pg_split_opts(char **argv, int *argcp, const char *optstr)
|
||||
{
|
||||
StringInfoData s;
|
||||
|
||||
@ -438,8 +438,8 @@ pg_split_opts(char **argv, int *argcp, char *optstr)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Parse a single option + value, stopping at the first space, unless
|
||||
* it's escaped.
|
||||
* Parse a single option, stopping at the first space, unless it's
|
||||
* escaped.
|
||||
*/
|
||||
while (*optstr)
|
||||
{
|
||||
@ -457,10 +457,11 @@ pg_split_opts(char **argv, int *argcp, char *optstr)
|
||||
optstr++;
|
||||
}
|
||||
|
||||
/* now store the option */
|
||||
/* now store the option in the next argv[] position */
|
||||
argv[(*argcp)++] = pstrdup(s.data);
|
||||
}
|
||||
resetStringInfo(&s);
|
||||
|
||||
pfree(s.data);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user