Poco::Data::PostGreSQL::SessionHandle: free _pConnection when connection attempt fails.

This commit is contained in:
Friedrich Wilckens 2023-10-29 13:53:11 -07:00
parent 3da8ee633e
commit c7b6fa17be

View File

@ -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;