mirror of
https://github.com/postgres/postgres.git
synced 2025-08-22 21:53:06 +03:00
Fix memory and file descriptor leaks in pg_receivexlog/pg_basebackup
When the internal loop mode was added, freeing memory and closing filedescriptors before returning became important, and a few cases in the code missed that. Fujii Masao
This commit is contained in:
@@ -143,6 +143,17 @@ GetConnection(void)
|
||||
|
||||
tmpconn = PQconnectdbParams(keywords, values, true);
|
||||
|
||||
/*
|
||||
* If there is too little memory even to allocate the PGconn object
|
||||
* and PQconnectdbParams returns NULL, we call exit(1) directly.
|
||||
*/
|
||||
if (!tmpconn)
|
||||
{
|
||||
fprintf(stderr, _("%s: could not connect to server\n"),
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (PQstatus(tmpconn) == CONNECTION_BAD &&
|
||||
PQconnectionNeedsPassword(tmpconn) &&
|
||||
dbgetpassword != -1)
|
||||
@@ -154,8 +165,11 @@ GetConnection(void)
|
||||
|
||||
if (PQstatus(tmpconn) != CONNECTION_OK)
|
||||
{
|
||||
fprintf(stderr, _("%s: could not connect to server: %s"),
|
||||
fprintf(stderr, _("%s: could not connect to server: %s\n"),
|
||||
progname, PQerrorMessage(tmpconn));
|
||||
PQfinish(tmpconn);
|
||||
free(values);
|
||||
free(keywords);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user