Connection leak in dblink on duplicate names
Started by Takahiro Itagakiover 15 years ago1 messages
I found contrib/dblink leaks a connection or a small amout of memory
when dblink_connect() ends with a duplicate connection name error.
We should disconnect the connection before raise any ERRORs.
Patch attached.
Regards,
---
Takahiro Itagaki
NTT Open Source Software Center
Attachments:
dblink-connection-leak.patchapplication/octet-stream; name=dblink-connection-leak.patchDownload
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index deaddfb..9a9ee19 100644
*** a/contrib/dblink/dblink.c
--- b/contrib/dblink/dblink.c
*************** createNewConnection(const char *name, re
*** 2237,2245 ****
--- 2237,2250 ----
HASH_ENTER, &found);
if (found)
+ {
+ PQfinish(rconn->conn);
+ pfree(rconn);
+
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("duplicate connection name")));
+ }
hentry->rconn = rconn;
strlcpy(hentry->name, name, sizeof(hentry->name));