diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-04-17 10:56:03 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-04-17 10:57:00 +0900 |
commit | 6a964dcf0fe3b9258d07391ada0f0d245b1f7cec (patch) | |
tree | b9af585607c69e5f8ccd227931eab42a4f9b824c /i18npool/source/textconversion/textconversion_zh.cxx | |
parent | 326f8dc37bc11591e7d683b21085da7ee15b8072 (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: Ibadadacbe09a93e7d7a7210868c52a8fa582d427
Diffstat (limited to 'i18npool/source/textconversion/textconversion_zh.cxx')
-rw-r--r-- | i18npool/source/textconversion/textconversion_zh.cxx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/i18npool/source/textconversion/textconversion_zh.cxx b/i18npool/source/textconversion/textconversion_zh.cxx index a4a4a1b81f64..db800f8a6031 100644 --- a/i18npool/source/textconversion/textconversion_zh.cxx +++ b/i18npool/source/textconversion/textconversion_zh.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/linguistic2/ConversionDictionaryType.hpp> #include <com/sun/star/linguistic2/ConversionDictionaryList.hpp> #include <comphelper/string.hxx> +#include <boost/scoped_array.hpp> using namespace com::sun::star::lang; using namespace com::sun::star::i18n; @@ -164,7 +165,7 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, if ((!wordData || !index || !entry) && !xCDL.is()) // no word mapping defined, do char2char conversion. return getCharConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions); - sal_Unicode *newStr = new sal_Unicode[nLength * 2 + 1]; + boost::scoped_array<sal_Unicode> newStr(new sal_Unicode[nLength * 2 + 1]); sal_Int32 currPos = 0, count = 0; while (currPos < nLength) { sal_Int32 len = nLength - currPos; @@ -259,8 +260,7 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, } if (offset.getLength() > 0) offset.realloc(one2one ? 0 : count); - OUString aRet(newStr, count); - delete[] newStr; + OUString aRet(newStr.get(), count); return aRet; } |