From a1c259793fd89dc753c7d13c101d4c5257a86259 Mon Sep 17 00:00:00 2001
From: Dan Goodliffe <dan@randomdan.homeip.net>
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(-)

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