I offer the attached patch under LGPLv3+/MPL1.1 dual license or future versions of the licenses,
It fixes a leak of connection handle in an ODBC database. Without the call to SQLDisconnect90, SQLFreeHandle() fails with code 'HY010'. This is my first attempt a patch. Comments and guidance welcome. Terry.
>From a479ceb4fae631640c15f35f1cd8b91513632324 Mon Sep 17 00:00:00 2001 From: Terrence Enger <ten...@iseries-guru.com> Date: Thu, 27 Oct 2011 16:37:50 -0400 Subject: [PATCH] leaking connection handle 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
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice