From 24a3e9e046e125a60fe35599bc9776b33b31038c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 6 Dec 2015 00:41:44 +0000 Subject: Fix connection leak on connect failure --- libpqpp/connection.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libpqpp/connection.cpp') 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); } -- cgit v1.2.3