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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Sun Jun 20 18:39:30 UTC 2021


 sw/source/filter/ww8/ww8par.cxx |   32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

New commits:
commit e59ab5306e308ccf44ba1a3f39ec73c34b3d387d
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Jun 20 17:42:14 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Jun 20 20:38:54 2021 +0200

    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 at redhat.com>

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 );


More information about the Libreoffice-commits mailing list