diff options
Diffstat (limited to 'basic/source/runtime/methods.cxx')
-rw-r--r-- | basic/source/runtime/methods.cxx | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 07e37f2bb6b5..aad84105a293 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -3718,10 +3718,10 @@ RTLFUNC(Shell) ++iter; sal_uInt16 nParamCount = sal::static_int_cast< sal_uInt16 >(aTokenList.size() - 1 ); - rtl_uString** pParamList = nullptr; + std::unique_ptr<rtl_uString*[]> pParamList; if( nParamCount ) { - pParamList = new rtl_uString*[nParamCount]; + pParamList.reset( new rtl_uString*[nParamCount]); for(int iList = 0; iter != aTokenList.end(); ++iList, ++iter) { const OUString& rParamStr = (*iter); @@ -3734,7 +3734,7 @@ RTLFUNC(Shell) oslProcess pApp; bool bSucc = osl_executeProcess( aOUStrProgURL.pData, - pParamList, + pParamList.get(), nParamCount, nOptions, nullptr, @@ -3753,8 +3753,6 @@ RTLFUNC(Shell) rtl_uString_release(pParamList[j]); } - delete [] pParamList; - if( !bSucc ) { StarBASIC::Error( ERRCODE_BASIC_FILE_NOT_FOUND ); @@ -4352,7 +4350,7 @@ RTLFUNC(StrConv) // convert the string to byte string, preserving unicode (2 bytes per character) sal_Int32 nSize = aNewStr.getLength()*2; const sal_Unicode* pSrc = aNewStr.getStr(); - sal_Char* pChar = new sal_Char[nSize+1]; + std::unique_ptr<sal_Char[]> pChar(new sal_Char[nSize+1]); for( sal_Int32 i=0; i < nSize; i++ ) { pChar[i] = static_cast< sal_Char >( (i%2) ? ((*pSrc) >> 8) & 0xff : (*pSrc) & 0xff ); @@ -4362,8 +4360,7 @@ RTLFUNC(StrConv) } } pChar[nSize] = '\0'; - OString aOStr(pChar); - delete[] pChar; + OString aOStr(pChar.get()); // there is no concept about default codepage in unix. so it is incorrectly in unix OUString aOUStr = OStringToOUString(aOStr, osl_getThreadTextEncoding()); |