1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-02 11:44:50 +03:00

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
This commit is contained in:
Peter Eisentraut 2012-03-16 20:30:19 +02:00
parent 598bb8cdbd
commit d4318483e1

View File

@ -4303,6 +4303,7 @@ conninfo_array_parse(const char *const * keywords, const char *const * values,
{ {
printfPQExpBuffer(errorMessage, printfPQExpBuffer(errorMessage,
libpq_gettext("out of memory\n")); libpq_gettext("out of memory\n"));
PQconninfoFree(str_options);
return NULL; return NULL;
} }
memcpy(options, PQconninfoOptions, sizeof(PQconninfoOptions)); 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"), libpq_gettext("invalid connection option \"%s\"\n"),
pname); pname);
PQconninfoFree(options); PQconninfoFree(options);
PQconninfoFree(str_options);
return NULL; return NULL;
} }
@ -4374,6 +4376,7 @@ conninfo_array_parse(const char *const * keywords, const char *const * values,
printfPQExpBuffer(errorMessage, printfPQExpBuffer(errorMessage,
libpq_gettext("out of memory\n")); libpq_gettext("out of memory\n"));
PQconninfoFree(options); PQconninfoFree(options);
PQconninfoFree(str_options);
return NULL; return NULL;
} }
} }