diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-10-21 13:20:18 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-10-21 15:08:51 +0200 |
commit | 137131b1e0c81bb948e563f831cfe9e6ebfb1b3f (patch) | |
tree | d8f57ee05886b5201d4e36535a34f65e9f4e1499 /connectivity | |
parent | 666ec98b7e10ca8acd891363587fd345373b3716 (diff) |
connectivity: firebird: fix Connection leak in OStatementCommonBase
bin/refcount_leak.py was very helpful here.
Change-Id: I61dc57408cf1533f733c08b701884851ec6afb8d
Diffstat (limited to 'connectivity')
5 files changed, 7 insertions, 10 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index 065440716bfd..ac37c525e341 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -152,7 +152,7 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData() ensurePrepared(); if(!m_xMetaData.is()) - m_xMetaData = new OResultSetMetaData(m_pConnection, m_pOutSqlda); + m_xMetaData = new OResultSetMetaData(m_pConnection.get(), m_pOutSqlda); return m_xMetaData; } @@ -239,7 +239,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection() MutexGuard aGuard( m_aMutex ); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); - return Reference< XConnection >(m_pConnection); + return Reference<XConnection>(m_pConnection.get()); } sal_Bool SAL_CALL OPreparedStatement::execute() @@ -282,7 +282,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute() evaluateStatusVector(m_statusVector, "isc_dsql_execute", *this); } - m_xResultSet = new OResultSet(m_pConnection, + m_xResultSet = new OResultSet(m_pConnection.get(), m_aMutex, uno::Reference< XInterface >(*this), m_aStatementHandle, diff --git a/connectivity/source/drivers/firebird/ResultSet.hxx b/connectivity/source/drivers/firebird/ResultSet.hxx index 90c2b9fca550..dbb971afad39 100644 --- a/connectivity/source/drivers/firebird/ResultSet.hxx +++ b/connectivity/source/drivers/firebird/ResultSet.hxx @@ -79,6 +79,7 @@ namespace connectivity sal_Int32 m_nResultSetConcurrency; protected: + // Connection kept alive by m_xStatement Connection* m_pConnection; ::osl::Mutex& m_rMutex; const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& m_xStatement; diff --git a/connectivity/source/drivers/firebird/Statement.cxx b/connectivity/source/drivers/firebird/Statement.cxx index 42478941dc1f..59e5ff8f77d7 100644 --- a/connectivity/source/drivers/firebird/Statement.cxx +++ b/connectivity/source/drivers/firebird/Statement.cxx @@ -125,7 +125,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s if (aErr) SAL_WARN("connectivity.firebird", "isc_dsql_execute failed"); - m_xResultSet = new OResultSet(m_pConnection, + m_xResultSet = new OResultSet(m_pConnection.get(), m_aMutex, uno::Reference< XInterface >(*this), m_aStatementHandle, @@ -162,7 +162,7 @@ uno::Reference< XConnection > SAL_CALL OStatement::getConnection() MutexGuard aGuard(m_aMutex); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); - return uno::Reference< XConnection >(m_pConnection); + return uno::Reference<XConnection>(m_pConnection.get()); } Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException, std::exception) diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx index 5daa56da013c..e6a67e4cbd78 100644 --- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx +++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx @@ -51,7 +51,6 @@ OStatementCommonBase::OStatementCommonBase(Connection* _pConnection) m_aStatementHandle( 0 ), rBHelper(OStatementCommonBase_Base::rBHelper) { - m_pConnection->acquire(); } OStatementCommonBase::~OStatementCommonBase() diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.hxx b/connectivity/source/drivers/firebird/StatementCommonBase.hxx index 3591d22307f5..60ac91533450 100644 --- a/connectivity/source/drivers/firebird/StatementCommonBase.hxx +++ b/connectivity/source/drivers/firebird/StatementCommonBase.hxx @@ -60,7 +60,7 @@ namespace connectivity ::std::list< ::rtl::OUString> m_aBatchList; - Connection* m_pConnection; + ::rtl::Reference<Connection> m_pConnection; ISC_STATUS_ARRAY m_statusVector; isc_stmt_handle m_aStatementHandle; @@ -136,9 +136,6 @@ namespace connectivity // XCloseable virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; - // other methods - Connection* getOwnConnection() const { return m_pConnection;} - }; } } |