[Libreoffice-commits] core.git: sw/source

Caolán McNamara caolanm at redhat.com
Mon Apr 3 19:34:56 UTC 2017


 sw/source/filter/ww8/ww8par.cxx |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

New commits:
commit aec5912b1377a36c68673b175fa8e2ad7673d2fa
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Apr 3 16:41:24 2017 +0100

    ofz: avoid oom
    
    Change-Id: Icbd4b98e8a0a4aff967bae22f3f59248ed40598a
    Reviewed-on: https://gerrit.libreoffice.org/36049
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-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 29aa054ad05a..eb7d6f9663a2 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2951,6 +2951,20 @@ sal_Unicode SwWW8ImplReader::TranslateToHindiNumbers(sal_Unicode nChar)
     return nChar;
 }
 
+namespace
+{
+    OUString makeOUString(rtl_uString *pStr, sal_Int32 nAllocLen)
+    {
+        //if read len was in or around that of allocated len, just reuse pStr
+        if (nAllocLen < pStr->length + 256)
+            return OUString(pStr, SAL_NO_ACQUIRE);
+        //otherwise copy the shorter used section to release extra mem
+        OUString sRet(pStr->buffer, pStr->length);
+        rtl_uString_release(pStr);
+        return sRet;
+    }
+}
+
 /**
  * Return value: true for non special chars
  */
@@ -3125,7 +3139,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp
         pStr->buffer[nEndUsed] = 0;
         pStr->length = nEndUsed;
 
-        emulateMSWordAddTextToParagraph(OUString(pStr, SAL_NO_ACQUIRE));
+        emulateMSWordAddTextToParagraph(makeOUString(pStr, nStrLen));
         pStr = nullptr;
         rPos += nL2;
         if (!m_aApos.back()) // a para end in apo doesn't count


More information about the Libreoffice-commits mailing list