summaryrefslogtreecommitdiff
path: root/libpqpp/connection.cpp
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
commita1c259793fd89dc753c7d13c101d4c5257a86259 (patch)
tree29072eb84490967c538891265f0f7712b7a09e90 /libpqpp/connection.cpp
parentEnable gc-sections in release (diff)
downloadlibdbpp-postgresql-a1c259793fd89dc753c7d13c101d4c5257a86259.tar.bz2
libdbpp-postgresql-a1c259793fd89dc753c7d13c101d4c5257a86259.tar.xz
libdbpp-postgresql-a1c259793fd89dc753c7d13c101d4c5257a86259.zip
Fix connection leak on connect failure
Diffstat (limited to 'libpqpp/connection.cpp')
-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);
}