Kaydet (Commit) 19669b2c authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Markus Mohrhard

fix memory leak when exception is thrown

Change-Id: Ie9702da32f27134f0c2c263fcded417c51a17b2a
Reviewed-on: https://gerrit.libreoffice.org/14167Tested-by: 's avatarJenkins <ci@libreoffice.org>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 9266abdb
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include "resource/sharedresources.hxx" #include "resource/sharedresources.hxx"
#include <memory>
using namespace connectivity; using namespace connectivity;
using namespace connectivity::ado; using namespace connectivity::ado;
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
...@@ -118,10 +120,12 @@ Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const S ...@@ -118,10 +120,12 @@ Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const S
if ( ! acceptsURL(url) ) if ( ! acceptsURL(url) )
return NULL; 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); pCon->construct(url,info);
Reference< XConnection > xCon = pCon; OConnection* pPtr = pCon.get();
m_xConnections.push_back(WeakReferenceHelper(*pCon)); Reference< XConnection > xCon = pCon.release();
m_xConnections.push_back(WeakReferenceHelper(*pPtr));
return xCon; return xCon;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment