diff options
author | Armin Le Grand <alg@apache.org> | 2013-10-16 16:47:38 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2013-10-16 15:55:05 +0000 |
commit | dfa1afd0e8b7ae9c706c4a3171a04752e24230b0 (patch) | |
tree | 8671d2d43b52426fd2c6efa0479f8b165a0c21ff /sot | |
parent | 4d392f9132e5e21f0da7c043bd41a32921e0f41f (diff) |
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@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sot')
-rw-r--r-- | sot/source/sdstor/stgstrms.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx index 1afbf2125527..16deea9168ba 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) |