diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-06-20 17:42:14 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-06-20 20:38:54 +0200 |
commit | e59ab5306e308ccf44ba1a3f39ec73c34b3d387d (patch) | |
tree | 8860b2f8b6ec6d539b425a2ecae13cad6c89452e | |
parent | f2bcf8f5b383232a4f9f345b94f4b40b646edb22 (diff) |
ofz#34221 avoid OOM
Change-Id: I1987d39ea8ff195b397b0ee3fb0e45f9bfbfb572
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117515
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index ec316678e96b..20e85c4c1c36 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -6056,23 +6056,25 @@ const OUString* SwWW8ImplReader::GetAnnotationAuthor(sal_uInt16 nIdx) m_xAtnNames.emplace(); SvStream& rStrm = *m_pTableStream; - tools::Long nOldPos = rStrm.Tell(); - rStrm.Seek( m_xWwFib->m_fcGrpStAtnOwners ); - - tools::Long nRead = 0, nCount = m_xWwFib->m_lcbGrpStAtnOwners; - while (nRead < nCount && rStrm.good()) + auto nOldPos = rStrm.Tell(); + bool bValidPos = checkSeek(rStrm, m_xWwFib->m_fcGrpStAtnOwners); + if (bValidPos) { - if( m_bVer67 ) - { - m_xAtnNames->push_back(read_uInt8_PascalString(rStrm, - RTL_TEXTENCODING_MS_1252)); - nRead += m_xAtnNames->rbegin()->getLength() + 1; // Length + sal_uInt8 count - } - else + tools::Long nRead = 0, nCount = m_xWwFib->m_lcbGrpStAtnOwners; + while (nRead < nCount && rStrm.good()) { - m_xAtnNames->push_back(read_uInt16_PascalString(rStrm)); - // Unicode: double the length + sal_uInt16 count - nRead += (m_xAtnNames->rbegin()->getLength() + 1)*2; + if( m_bVer67 ) + { + m_xAtnNames->push_back(read_uInt8_PascalString(rStrm, + RTL_TEXTENCODING_MS_1252)); + nRead += m_xAtnNames->rbegin()->getLength() + 1; // Length + sal_uInt8 count + } + else + { + m_xAtnNames->push_back(read_uInt16_PascalString(rStrm)); + // Unicode: double the length + sal_uInt16 count + nRead += (m_xAtnNames->rbegin()->getLength() + 1)*2; + } } } rStrm.Seek( nOldPos ); |