diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-06 00:41:44 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-06 00:41:44 +0000 |
commit | a1c259793fd89dc753c7d13c101d4c5257a86259 (patch) | |
tree | 29072eb84490967c538891265f0f7712b7a09e90 | |
parent | Enable gc-sections in release (diff) | |
download | libdbpp-postgresql-a1c259793fd89dc753c7d13c101d4c5257a86259.tar.bz2 libdbpp-postgresql-a1c259793fd89dc753c7d13c101d4c5257a86259.tar.xz libdbpp-postgresql-a1c259793fd89dc753c7d13c101d4c5257a86259.zip |
Fix connection leak on connect failure
-rw-r--r-- | libpqpp/connection.cpp | 4 |
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); } |