[PATCH] leaking connection handle

Terrence Enger tenger at iseries-guru.com
Thu Oct 27 13:37:50 PDT 2011


call SQLDisconnect;
check returns from SQLDisconnect and SQLFreeHandle
---
 .../source/drivers/odbcbase/OConnection.cxx        |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/connectivity/source/drivers/odbcbase/OConnection.cxx b/connectivity/source/drivers/odbcbase/OConnection.cxx
index 891eabc..03bc39b 100644
--- a/connectivity/source/drivers/odbcbase/OConnection.cxx
+++ b/connectivity/source/drivers/odbcbase/OConnection.cxx
@@ -78,8 +78,24 @@ OConnection::~OConnection()
         close();
 
     if ( SQL_NULL_HANDLE != m_aConnectionHandle )
-        N3SQLFreeHandle( SQL_HANDLE_DBC, m_aConnectionHandle );
-    m_aConnectionHandle = SQL_NULL_HANDLE;
+    {
+        SQLRETURN rc;
+
+        rc = N3SQLDisconnect( m_aConnectionHandle );
+        if ( SQL_SUCCESS           != rc &&
+             SQL_SUCCESS_WITH_INFO != rc )
+            OSL_TRACE( "Failure from SQLDisconnect, %s:%i"
+                     , __FILE__, __LINE__
+                     );
+
+        rc = N3SQLFreeHandle( SQL_HANDLE_DBC, m_aConnectionHandle );
+        if ( SQL_SUCCESS != rc )
+            OSL_TRACE( "Failure from SQLFreeHandle for connection, %s:%i"
+                     , __FILE__, __LINE__
+                     );
+
+        m_aConnectionHandle = SQL_NULL_HANDLE;
+    }
 
     m_pDriver->release();
     m_pDriver = NULL;
-- 
1.7.4.1


--=-iKf9MgSRdA0ODdBI6VeR--



More information about the LibreOffice mailing list