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

Armin Le Grand alg at apache.org
Wed Oct 16 08:55:26 PDT 2013


 sot/source/sdstor/stgstrms.cxx |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

New commits:
commit dfa1afd0e8b7ae9c706c4a3171a04752e24230b0
Author: Armin Le Grand <alg at apache.org>
Date:   Wed Oct 16 16:47:38 2013 +0100

    i123485 secured file import scanning existing pages
    
    (cherry picked from commit 04b38114b0ca4be9895d8f9fa842b6cb390c8036
     and adapted to the rewritten scanBuildPageChainCache)
    
    Change-Id: Ib90d0563be5aeb69aa14c28b3304e42f3cc46162
    Reviewed-on: https://gerrit.libreoffice.org/6272
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx
index 1afbf21..16deea9 100644
--- a/sot/source/sdstor/stgstrms.cxx
+++ b/sot/source/sdstor/stgstrms.cxx
@@ -23,6 +23,7 @@
 #include <sal/log.hxx>
 #include <osl/file.hxx>
 #include <unotools/tempfile.hxx>
+#include <set>
 
 #include "sot/stg.hxx"
 #include "stgelem.hxx"
@@ -339,16 +340,23 @@ void StgStrm::scanBuildPageChainCache(sal_Int32 *pOptionalCalcSize)
 
     bool bError = false;
     sal_Int32 nBgn = nStart;
-    sal_Int32 nOldBgn = -1;
     sal_Int32 nOptSize = 0;
-    while( nBgn >= 0 && nBgn != nOldBgn )
+
+    // Track already scanned PageNumbers here and use them to
+    // see if an  already counted page is re-visited
+    std::set< sal_Int32 > nUsedPageNumbers;
+
+    while( nBgn >= 0 && !bError )
     {
         if( nBgn >= 0 )
             m_aPagesCache.push_back(nBgn);
-        nOldBgn = nBgn;
         nBgn = pFat->GetNextPage( nBgn );
-        if( nBgn == nOldBgn )
+
+        if( nUsedPageNumbers.find(nBgn) != nUsedPageNumbers.end() )
             bError = true;
+        else
+            nUsedPageNumbers.insert(nBgn);
+
         nOptSize += nPageSize;
     }
     if (bError)


More information about the Libreoffice-commits mailing list