summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-03-13 14:57:50 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-03-13 20:24:26 +0000
commit4eda033a0077b608a9a17ffb09485ad3d7dc0948 (patch)
tree8f6dfad3ea366dcd1dba22ae52ffa317e5c038e7 /tools
parent73858eed8e144c3cd9fcdae786e015ca325b9c11 (diff)
ofz#853 oom in svm
Change-Id: Ibe41e1edb717b4e740971f4b972abdea769460eb
Diffstat (limited to 'tools')
-rw-r--r--tools/source/stream/stream.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index f838edbf6087..b1efb6952495 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1961,7 +1961,9 @@ OString read_uInt8s_ToOString(SvStream& rStrm, std::size_t nLen)
rtl_String *pStr = nullptr;
if (nLen)
{
- nLen = std::min(nLen, static_cast<std::size_t>(SAL_MAX_INT32));
+ nLen = std::min<std::size_t>(nLen, SAL_MAX_INT32);
+ //limit allocation to size of file, but + 1 to set eof state
+ nLen = std::min<sal_uInt64>(nLen, rStrm.remainingSize() + 1);
//alloc a (ref-count 1) rtl_String of the desired length.
//rtl_String's buffer is uninitialized, except for null termination
pStr = rtl_string_alloc(sal::static_int_cast<sal_Int32>(nLen));
@@ -1990,7 +1992,9 @@ OUString read_uInt16s_ToOUString(SvStream& rStrm, std::size_t nLen)
rtl_uString *pStr = nullptr;
if (nLen)
{
- nLen = std::min(nLen, static_cast<std::size_t>(SAL_MAX_INT32));
+ nLen = std::min<std::size_t>(nLen, SAL_MAX_INT32);
+ //limit allocation to size of file, but + 1 to set eof state
+ nLen = std::min<sal_uInt64>(nLen, (rStrm.remainingSize() + 2) / 2);
//alloc a (ref-count 1) rtl_uString of the desired length.
//rtl_String's buffer is uninitialized, except for null termination
pStr = rtl_uString_alloc(sal::static_int_cast<sal_Int32>(nLen));