diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-06-29 12:42:52 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-06-29 12:42:52 -0400 |
commit | cbc8d65639344c390a1d1a7f646c186ff3ad8693 (patch) | |
tree | 46c7ad96d8f554aea527f30247363f4fc85f8ef5 /src/backend/utils/init/postinit.c | |
parent | 07cb8b02ab4c8b65bb2e3b87ad2402fdc6cce978 (diff) | |
download | postgresql-cbc8d65639344c390a1d1a7f646c186ff3ad8693.tar.gz postgresql-cbc8d65639344c390a1d1a7f646c186ff3ad8693.zip |
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.
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r-- | src/backend/utils/init/postinit.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 0e7b5fad2dd..063b0653b49 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -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); } /* |