Fix libpq memory leak during PQreset() --- closePGconn() was not
freeing all transient state of the PGconn object.
This commit is contained in:
parent
a5d10d66d1
commit
57bdab7d35
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.263.2.2 2005/05/05 16:37:04 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.263.2.3 2005/07/13 15:26:16 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1999,6 +1999,8 @@ makeEmptyPGconn(void)
|
|||||||
/*
|
/*
|
||||||
* freePGconn
|
* freePGconn
|
||||||
* - free the PGconn data structure
|
* - free the PGconn data structure
|
||||||
|
*
|
||||||
|
* When changing/adding to this function, see also closePGconn!
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
freePGconn(PGconn *conn)
|
freePGconn(PGconn *conn)
|
||||||
@ -2041,9 +2043,9 @@ freePGconn(PGconn *conn)
|
|||||||
if (conn->sslmode)
|
if (conn->sslmode)
|
||||||
free(conn->sslmode);
|
free(conn->sslmode);
|
||||||
/* Note that conn->Pfdebug is not ours to close or free */
|
/* Note that conn->Pfdebug is not ours to close or free */
|
||||||
|
freeaddrinfo_all(conn->addrlist_family, conn->addrlist);
|
||||||
if (conn->notifyList)
|
if (conn->notifyList)
|
||||||
DLFreeList(conn->notifyList);
|
DLFreeList(conn->notifyList);
|
||||||
freeaddrinfo_all(conn->addrlist_family, conn->addrlist);
|
|
||||||
pstatus = conn->pstatus;
|
pstatus = conn->pstatus;
|
||||||
while (pstatus != NULL)
|
while (pstatus != NULL)
|
||||||
{
|
{
|
||||||
@ -2066,10 +2068,14 @@ freePGconn(PGconn *conn)
|
|||||||
/*
|
/*
|
||||||
* closePGconn
|
* closePGconn
|
||||||
* - properly close a connection to the backend
|
* - properly close a connection to the backend
|
||||||
|
*
|
||||||
|
* Release all transient state, but NOT the connection parameters.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
closePGconn(PGconn *conn)
|
closePGconn(PGconn *conn)
|
||||||
{
|
{
|
||||||
|
pgParameterStatus *pstatus;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that the protocol doesn't allow us to send Terminate messages
|
* Note that the protocol doesn't allow us to send Terminate messages
|
||||||
* during the startup phase.
|
* during the startup phase.
|
||||||
@ -2105,6 +2111,21 @@ closePGconn(PGconn *conn)
|
|||||||
* absent */
|
* absent */
|
||||||
conn->asyncStatus = PGASYNC_IDLE;
|
conn->asyncStatus = PGASYNC_IDLE;
|
||||||
pqClearAsyncResult(conn); /* deallocate result and curTuple */
|
pqClearAsyncResult(conn); /* deallocate result and curTuple */
|
||||||
|
freeaddrinfo_all(conn->addrlist_family, conn->addrlist);
|
||||||
|
conn->addrlist = NULL;
|
||||||
|
conn->addr_cur = NULL;
|
||||||
|
if (conn->notifyList)
|
||||||
|
DLFreeList(conn->notifyList);
|
||||||
|
conn->notifyList = NULL;
|
||||||
|
pstatus = conn->pstatus;
|
||||||
|
while (pstatus != NULL)
|
||||||
|
{
|
||||||
|
pgParameterStatus *prev = pstatus;
|
||||||
|
|
||||||
|
pstatus = pstatus->next;
|
||||||
|
free(prev);
|
||||||
|
}
|
||||||
|
conn->pstatus = NULL;
|
||||||
if (conn->lobjfuncs)
|
if (conn->lobjfuncs)
|
||||||
free(conn->lobjfuncs);
|
free(conn->lobjfuncs);
|
||||||
conn->lobjfuncs = NULL;
|
conn->lobjfuncs = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user