summaryrefslogtreecommitdiff
path: root/libpqpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-12-06 00:41:44 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-12-06 00:41:44 +0000
commit24a3e9e046e125a60fe35599bc9776b33b31038c (patch)
tree1405d1b57e051e2d3cc8f3e7dee956f1db91cdcc /libpqpp
parentEnable gc-sections in release (diff)
downloadlibdbpp-postgresql-24a3e9e046e125a60fe35599bc9776b33b31038c.tar.bz2
libdbpp-postgresql-24a3e9e046e125a60fe35599bc9776b33b31038c.tar.xz
libdbpp-postgresql-24a3e9e046e125a60fe35599bc9776b33b31038c.zip
Fix connection leak on connect failure
Diffstat (limited to 'libpqpp')
-rw-r--r--libpqpp/connection.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/libpqpp/connection.cpp b/libpqpp/connection.cpp
index e47d846..57531e3 100644
--- a/libpqpp/connection.cpp
+++ b/libpqpp/connection.cpp
@@ -26,7 +26,9 @@ PQ::Connection::Connection(const std::string & info) :
rolledback(false)
{
if (PQstatus(conn) != CONNECTION_OK) {
- throw ConnectionError(conn);
+ ConnectionError ce(conn);
+ PQfinish(conn);
+ throw ce;
}
PQsetNoticeProcessor(conn, noNoticeProcessor, NULL);
}