[Libreoffice-commits] core.git: connectivity/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Mon Jan 26 18:16:39 PST 2015


 connectivity/source/drivers/ado/ADriver.cxx |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

New commits:
commit 19669b2c2d77ddf5d7a07a655ca21d0557e7d603
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun Jan 25 10:29:49 2015 +0100

    fix memory leak when exception is thrown
    
    Change-Id: Ie9702da32f27134f0c2c263fcded417c51a17b2a
    Reviewed-on: https://gerrit.libreoffice.org/14167
    Tested-by: Jenkins <ci at libreoffice.org>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/connectivity/source/drivers/ado/ADriver.cxx b/connectivity/source/drivers/ado/ADriver.cxx
index 69f38d8..3b9907d 100644
--- a/connectivity/source/drivers/ado/ADriver.cxx
+++ b/connectivity/source/drivers/ado/ADriver.cxx
@@ -31,6 +31,8 @@
 
 #include "resource/sharedresources.hxx"
 
+#include <memory>
+
 using namespace connectivity;
 using namespace connectivity::ado;
 using namespace com::sun::star::uno;
@@ -118,10 +120,12 @@ Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const S
     if ( ! acceptsURL(url) )
         return NULL;
 
-    OConnection* pCon = new OConnection(this);
+    // we need to wrap the connection as the construct call might throw
+    std::unique_ptr<OConnection> pCon(new OConnection(this));
     pCon->construct(url,info);
-    Reference< XConnection > xCon = pCon;
-    m_xConnections.push_back(WeakReferenceHelper(*pCon));
+    OConnection* pPtr = pCon.get();
+    Reference< XConnection > xCon = pCon.release();
+    m_xConnections.push_back(WeakReferenceHelper(*pPtr));
 
     return xCon;
 }


More information about the Libreoffice-commits mailing list