Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a624356

Browse files
committed
Fix connection leak in dblink when dblink_connect() or dblink_connect_u()
end with "duplicate connection name" errors. Backported to release 7.4.
1 parent 016212e commit a624356

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

contrib/dblink/dblink.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Darko Prenosil <Darko.Prenosil@finteh.hr>
99
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
1010
*
11-
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.92 2010/06/03 09:38:33 itagaki Exp $
11+
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.93 2010/06/09 00:56:02 itagaki Exp $
1212
* Copyright (c) 2001-2010, PostgreSQL Global Development Group
1313
* ALL RIGHTS RESERVED;
1414
*
@@ -2237,9 +2237,14 @@ createNewConnection(const char *name, remoteConn *rconn)
22372237
HASH_ENTER, &found);
22382238

22392239
if (found)
2240+
{
2241+
PQfinish(rconn->conn);
2242+
pfree(rconn);
2243+
22402244
ereport(ERROR,
22412245
(errcode(ERRCODE_DUPLICATE_OBJECT),
22422246
errmsg("duplicate connection name")));
2247+
}
22432248

22442249
hentry->rconn = rconn;
22452250
strlcpy(hentry->name, name, sizeof(hentry->name));

0 commit comments

Comments
 (0)