diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-07-24 23:09:24 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-07-25 10:09:15 +0900 |
commit | a8b395bff2111d7bf086b4cb44081dce10cca364 (patch) | |
tree | ec4a4ebebe94fcd58b9c8508b8c403e32a2a9cfc /ucb/source/ucp/cmis | |
parent | 4f2f53e267956e68fac768391c9b83d45adbc29f (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: I9983e858c4e634b4cac8ad42fa9b06b7ccc167d6
Diffstat (limited to 'ucb/source/ucp/cmis')
-rw-r--r-- | ucb/source/ucp/cmis/cmis_repo_content.cxx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ucb/source/ucp/cmis/cmis_repo_content.cxx b/ucb/source/ucp/cmis/cmis_repo_content.cxx index 4d2504978388..ea99c3509063 100644 --- a/ucb/source/ucp/cmis/cmis_repo_content.cxx +++ b/ucb/source/ucp/cmis/cmis_repo_content.cxx @@ -37,6 +37,7 @@ #include "cmis_provider.hxx" #include "cmis_repo_content.hxx" #include "cmis_resultset.hxx" +#include <boost/scoped_ptr.hpp> #define OUSTR_TO_STDSTR(s) string( OUStringToOString( s, RTL_TEXTENCODING_UTF8 ).getStr() ) #define STD_TO_OUSTR( str ) OUString( str.c_str(), str.length( ), RTL_TEXTENCODING_UTF8 ) @@ -177,17 +178,16 @@ namespace cmis ALFRESCO_CLOUD_SCOPE, ALFRESCO_CLOUD_REDIRECT_URI, ALFRESCO_CLOUD_CLIENT_ID, ALFRESCO_CLOUD_CLIENT_SECRET ) ); - libcmis::Session* session = libcmis::SessionFactory::createSession( + boost::scoped_ptr<libcmis::Session> session(libcmis::SessionFactory::createSession( OUSTR_TO_STDSTR( m_aURL.getBindingUrl( ) ), - rUsername, rPassword, "", false, oauth2Data ); - if (session == NULL ) + rUsername, rPassword, "", false, oauth2Data )); + if (!session) ucbhelper::cancelCommandExecution( ucb::IOErrorCode_INVALID_DEVICE, uno::Sequence< uno::Any >( 0 ), xEnv, OUString( ) ); m_aRepositories = session->getRepositories( ); - delete session; } catch (const libcmis::Exception& e) { |