summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2015-01-25 10:29:49 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-01-27 02:16:03 +0000
commit19669b2c2d77ddf5d7a07a655ca21d0557e7d603 (patch)
tree476dbaa03eed0418edfe04d4f03a5df4cb1ff314 /connectivity
parent9266abdb548ce99ebd891080fa263e930c5234e1 (diff)
fix memory leak when exception is thrown
Change-Id: Ie9702da32f27134f0c2c263fcded417c51a17b2a Reviewed-on: https://gerrit.libreoffice.org/14167 Tested-by: Jenkins <ci@libreoffice.org> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/ado/ADriver.cxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/connectivity/source/drivers/ado/ADriver.cxx b/connectivity/source/drivers/ado/ADriver.cxx
index 69f38d859c7b..3b9907d275fe 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;
}