diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-03 16:41:24 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-03 19:34:28 +0000 |
commit | aec5912b1377a36c68673b175fa8e2ad7673d2fa (patch) | |
tree | 9e2be8ffe614a0dff4d9ee870676bee856386352 | |
parent | 6b4a149a656b29d162b2190f1849dc779cba0b0a (diff) |
ofz: avoid oom
Change-Id: Icbd4b98e8a0a4aff967bae22f3f59248ed40598a
Reviewed-on: https://gerrit.libreoffice.org/36049
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 16 |
1 files changed, 15 insertions, 1 deletions
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 |