From c7b6fa17bee8357cc9f14b29edd6e6cc3d01ac44 Mon Sep 17 00:00:00 2001 From: Friedrich Wilckens Date: Sun, 29 Oct 2023 13:53:11 -0700 Subject: [PATCH] Poco::Data::PostGreSQL::SessionHandle: free _pConnection when connection attempt fails. --- Data/PostgreSQL/src/SessionHandle.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Data/PostgreSQL/src/SessionHandle.cpp b/Data/PostgreSQL/src/SessionHandle.cpp index 3bc4aa843..65d18fb19 100644 --- a/Data/PostgreSQL/src/SessionHandle.cpp +++ b/Data/PostgreSQL/src/SessionHandle.cpp @@ -88,7 +88,13 @@ void SessionHandle::connect(const std::string& aConnectionString) if (!isConnectedNoLock()) { - throw ConnectionFailedException(std::string("Connection Error: ") + lastErrorNoLock()); + std::string msg = std::string("Connection Error: ") + lastErrorNoLock(); + if (_pConnection) + { + PQfinish(_pConnection); + _pConnection = 0; + } + throw ConnectionFailedException(msg); } _connectionString = aConnectionString;