summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-01-04 16:44:33 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-01-05 11:46:48 +0100
commitedb2f8af6998d91939ab53f95239ffdc9f092ed3 (patch)
treea0e3b3321e36f9b5f3bf323ec06e60c5703eecdc /sw/source/filter/ww8
parent658528342ec80c889c4afcf3c166997d55d785d4 (diff)
ofz#29219 Direct-leak
Change-Id: I190256bc9502d742ce182c0bef0698847fa77070 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108673 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/filter/ww8')
-rw-r--r--sw/source/filter/ww8/ww8par.cxx15
1 files changed, 6 insertions, 9 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 91b8f84557ae..3bb0686b2d85 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -3110,8 +3110,9 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp
RTL_TEXTENCODING_MS_1252;
// allocate unicode string data
- rtl_uString *pStr = rtl_uString_alloc(nStrLen);
- sal_Unicode* pBuffer = pStr->buffer;
+ auto l = [](rtl_uString* p){rtl_uString_release(p);};
+ std::unique_ptr<rtl_uString, decltype(l)> xStr(rtl_uString_alloc(nStrLen), l);
+ sal_Unicode* pBuffer = xStr->buffer;
sal_Unicode* pWork = pBuffer;
std::unique_ptr<char[]> p8Bits;
@@ -3146,7 +3147,6 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp
if (m_pStrm->GetError())
{
rPos = WW8_CP_MAX-10; // -> eof or other error
- std::free(pStr);
return true;
}
@@ -3194,11 +3194,10 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp
*pBuffer = TranslateToHindiNumbers(*pBuffer);
}
- pStr->buffer[nEndUsed] = 0;
- pStr->length = nEndUsed;
+ xStr->buffer[nEndUsed] = 0;
+ xStr->length = nEndUsed;
- emulateMSWordAddTextToParagraph(makeOUString(pStr, nStrLen));
- pStr = nullptr;
+ emulateMSWordAddTextToParagraph(makeOUString(xStr.release(), nStrLen));
rPos += nL2;
if (!m_aApos.back()) // a para end in apo doesn't count
m_bWasParaEnd = false; // No CR
@@ -3206,8 +3205,6 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp
if (hConverter)
rtl_destroyTextToUnicodeConverter(hConverter);
- if (pStr)
- rtl_uString_release(pStr);
return nL2 >= nStrLen;
}