From: Peter Eisentraut Date: Fri, 16 Mar 2012 18:30:19 +0000 (+0200) Subject: libpq: Fix minor memory leaks X-Git-Tag: REL9_2_BETA1~266 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d4318483e151b41cd663e7b36a5539d3c5048c5a;p=postgresql libpq: Fix minor memory leaks When using connection info arrays with a conninfo string in the dbname slot, some memory would be leaked if an error occurred while processing the following array slots. found by Coverity --- diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index eece99ab1d..817d83b9cb 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -4303,6 +4303,7 @@ conninfo_array_parse(const char *const * keywords, const char *const * values, { printfPQExpBuffer(errorMessage, libpq_gettext("out of memory\n")); + PQconninfoFree(str_options); return NULL; } memcpy(options, PQconninfoOptions, sizeof(PQconninfoOptions)); @@ -4330,6 +4331,7 @@ conninfo_array_parse(const char *const * keywords, const char *const * values, libpq_gettext("invalid connection option \"%s\"\n"), pname); PQconninfoFree(options); + PQconninfoFree(str_options); return NULL; } @@ -4374,6 +4376,7 @@ conninfo_array_parse(const char *const * keywords, const char *const * values, printfPQExpBuffer(errorMessage, libpq_gettext("out of memory\n")); PQconninfoFree(options); + PQconninfoFree(str_options); return NULL; } }