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/ftp | |
parent | 4f2f53e267956e68fac768391c9b83d45adbc29f (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: I9983e858c4e634b4cac8ad42fa9b06b7ccc167d6
Diffstat (limited to 'ucb/source/ucp/ftp')
-rw-r--r-- | ucb/source/ucp/ftp/ftpurl.cxx | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ucb/source/ucp/ftp/ftpurl.cxx b/ucb/source/ucp/ftp/ftpurl.cxx index 6b176a524c47..1fb36be4a2ae 100644 --- a/ucb/source/ucp/ftp/ftpurl.cxx +++ b/ucb/source/ucp/ftp/ftpurl.cxx @@ -38,6 +38,7 @@ #include "ftphandleprovider.hxx" #include "ftpcfunc.hxx" #include "ftpcontainer.hxx" +#include <boost/scoped_array.hpp> using namespace ftp; using namespace com::sun::star::ucb; @@ -159,17 +160,17 @@ void FTPURL::parse(const OUString& url) strncmp("ftp://",lower.getStr(),6)) throw malformed_exception(); - char *buffer = new char[1+aIdent.getLength()]; + boost::scoped_array<char> buffer(new char[1+aIdent.getLength()]); const char* p2 = aIdent.getStr(); p2 += 6; char ch; - char *p1 = buffer; // determine "username:password@host:port" + char *p1 = buffer.get(); // determine "username:password@host:port" while((ch = *p2++) != '/' && ch) *p1++ = ch; *p1 = 0; - OUString aExpr(buffer, strlen(buffer), RTL_TEXTENCODING_UTF8); + OUString aExpr(buffer.get(), strlen(buffer.get()), RTL_TEXTENCODING_UTF8); sal_Int32 l = aExpr.indexOf('@'); m_aHost = aExpr.copy(1+l); @@ -203,26 +204,26 @@ void FTPURL::parse(const OUString& url) } while(ch) { // now determine the pathsegments ... - p1 = buffer; + p1 = buffer.get(); while((ch = *p2++) != '/' && ch) *p1++ = ch; *p1 = 0; if(buffer[0]) { - if( strcmp(buffer,"..") == 0 && !m_aPathSegmentVec.empty() && m_aPathSegmentVec.back() != ".." ) + if( strcmp(buffer.get(),"..") == 0 && !m_aPathSegmentVec.empty() && m_aPathSegmentVec.back() != ".." ) m_aPathSegmentVec.pop_back(); - else if(strcmp(buffer,".") == 0) + else if(strcmp(buffer.get(),".") == 0) ; // Ignore else // This is a legal name. m_aPathSegmentVec.push_back( - OUString(buffer, - strlen(buffer), + OUString(buffer.get(), + strlen(buffer.get()), RTL_TEXTENCODING_UTF8)); } } - delete[] buffer; + buffer.reset(); if(m_bShowPassword) m_pFCP->setHost(m_aHost, |