From: Itagaki Takahiro Date: Wed, 9 Jun 2010 01:00:50 +0000 (+0000) Subject: Fix connection leak in dblink when dblink_connect() or dblink_connect_u() X-Git-Tag: REL7_4_30~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=71dca6e00075122e37a64b03d719f02b5e036569;p=thirdparty%2Fpostgresql.git Fix connection leak in dblink when dblink_connect() or dblink_connect_u() end with "duplicate connection name" errors. Backported to release 7.4. --- diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 18271b24f76..0bea6487ec3 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -1980,9 +1980,14 @@ createNewConnection(const char *name, remoteConn * con) errmsg("out of memory"))); if (found) + { + PQfinish(rconn->conn); + pfree(rconn); + ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), errmsg("duplicate connection name"))); + } hentry->rcon = con; strncpy(hentry->name, name, NAMEDATALEN - 1);