diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-11-22 15:32:13 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-11-22 15:50:39 -0500 |
commit | 9a1d0af4ad2cbd419115b453d811c141b80d872b (patch) | |
tree | ea1e9dd3554984a54a21ee541435f9b239bbe351 /src/interfaces/libpq/fe-connect.c | |
parent | 906bfcad7ba7cb3863fe0e2a7810be8e3cd84fbd (diff) |
Code review for commit 274bb2b3857cc987cfa21d14775cae9b0dababa5.
Avoid memory leak in conninfo_uri_parse_options. Use the current host
rather than the comma-separated list of host names when the host name
is needed for GSS, SSPI, or SSL authentication. Document the way
connect_timeout interacts with multiple host specifications.
Takayuki Tsunakawa
Diffstat (limited to 'src/interfaces/libpq/fe-connect.c')
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index ae85db9dd5a..3e9c45bc406 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -4931,7 +4931,7 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri, { int prefix_len; char *p; - char *buf; + char *buf = NULL; char *start; char prevchar = '\0'; char *user = NULL; @@ -4946,7 +4946,7 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri, { printfPQExpBuffer(errorMessage, libpq_gettext("out of memory\n")); - return false; + goto cleanup; } /* need a modifiable copy of the input URI */ @@ -4955,7 +4955,7 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri, { printfPQExpBuffer(errorMessage, libpq_gettext("out of memory\n")); - return false; + goto cleanup; } start = buf; @@ -5156,7 +5156,8 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri, cleanup: termPQExpBuffer(&hostbuf); termPQExpBuffer(&portbuf); - free(buf); + if (buf) + free(buf); return retval; } |