[Libreoffice-commits] core.git: sw/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jan 5 10:47:34 UTC 2021
sw/source/filter/ww8/ww8par.cxx | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
New commits:
commit edb2f8af6998d91939ab53f95239ffdc9f092ed3
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jan 4 16:44:33 2021 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jan 5 11:46:48 2021 +0100
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 at redhat.com>
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;
}
More information about the Libreoffice-commits
mailing list