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 <tenger@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
Context
- [Libreoffice] [PATCH] leaking connection handles · Terrence Enger
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.