diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-05-08 08:54:22 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-05-08 09:11:59 +0100 |
commit | 33013a5feb1cfbb8cb9ddd10083bc9ff470da160 (patch) | |
tree | fa0c9ce6f789c3e6b3504058d340e6eb09b41c61 | |
parent | 102e5ecb4b7fb5487077274f7eefdb2160119c59 (diff) |
ofz avoid oom
Change-Id: I1cbcdc0aec8596fce4a803f885b328e604dc22fd
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8struc.hxx | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 2e3e2fc9cf4a..df869cbc724b 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -6420,11 +6420,13 @@ MSOPropertyBag::MSOPropertyBag() { } -void MSOPropertyBag::Read(SvStream& rStream) +bool MSOPropertyBag::Read(SvStream& rStream) { rStream.ReadUInt16(m_nId); sal_uInt16 cProp(0); rStream.ReadUInt16(cProp); + if (!rStream.good()) + return false; rStream.SeekRel(2); // cbUnknown //each MSOProperty is 8 bytes in size const size_t nMaxPossibleRecords = rStream.remainingSize() / 8; @@ -6433,12 +6435,13 @@ void MSOPropertyBag::Read(SvStream& rStream) SAL_WARN("sw.ww8", cProp << " records claimed, but max possible is " << nMaxPossibleRecords); cProp = nMaxPossibleRecords; } - for (sal_uInt16 i = 0; i < cProp; ++i) + for (sal_uInt16 i = 0; i < cProp && rStream.good(); ++i) { MSOProperty aProperty; aProperty.Read(rStream); m_aProperties.push_back(aProperty); } + return rStream.good(); } void MSOPropertyBag::Write(WW8Export& rExport) @@ -6458,10 +6461,11 @@ void WW8SmartTagData::Read(SvStream& rStream, WW8_FC fcFactoidData, sal_uInt32 l return; m_aPropBagStore.Read(rStream); - while (rStream.Tell() < fcFactoidData + lcbFactoidData) + while (rStream.good() && rStream.Tell() < fcFactoidData + lcbFactoidData) { MSOPropertyBag aPropertyBag; - aPropertyBag.Read(rStream); + if (!aPropertyBag.Read(rStream)) + break; m_aPropBags.push_back(aPropertyBag); } diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx index 9eb87651695b..bddb909c85ef 100644 --- a/sw/source/filter/ww8/ww8struc.hxx +++ b/sw/source/filter/ww8/ww8struc.hxx @@ -1122,7 +1122,7 @@ class MSOPropertyBag { public: MSOPropertyBag(); - void Read(SvStream& rStream); + bool Read(SvStream& rStream); void Write(WW8Export& rExport); /// Matches MSOFactoidType::m_nId in MSOPropertyBagStore::m_aFactoidTypes. |