[Libreoffice-commits] .: Branch 'libreoffice-3-3' - sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Nov 29 13:19:46 PST 2010


 sc/source/filter/excel/exctools.cxx |   13 ++++++++++---
 sc/source/filter/inc/otlnbuff.hxx   |    1 +
 2 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 42485a770ac22f501b6bf6e94215dd42d267c48f
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Nov 29 16:07:40 2010 -0500

    Fixed use of incorrect integer type during import of outlines.
    
    I was supposed to use SCSIZE to store column / row position but was
    incorrectly using sal_uInt8.  This caused import of outlines from
    Excel document to entirely get screwed when the outline positions
    were > 255, and it was understandably so. :-P (fdo#31833)

diff --git a/sc/source/filter/excel/exctools.cxx b/sc/source/filter/excel/exctools.cxx
index f59fdff..527738e 100644
--- a/sc/source/filter/excel/exctools.cxx
+++ b/sc/source/filter/excel/exctools.cxx
@@ -97,6 +97,7 @@ RootData::~RootData()
 XclImpOutlineBuffer::XclImpOutlineBuffer( SCSIZE nNewSize ) :
     maLevels(0, nNewSize, 0),
     mpOutlineArray(NULL),
+    mnEndPos(nNewSize),
     mnMaxLevel(0),
     mbButtonAfter(true)
 {
@@ -125,12 +126,18 @@ void XclImpOutlineBuffer::MakeScOutline()
     if (!mpOutlineArray)
         return;
 
-    ::std::vector<sal_uInt8> aOutlineStack;
+    ::std::vector<SCSIZE> aOutlineStack;
     aOutlineStack.reserve(mnMaxLevel);
-    OutlineLevels::const_iterator itr = maLevels.begin(), itr_end = maLevels.end();
-    for (; itr != itr_end; ++itr)
+    OutlineLevels::const_iterator itr = maLevels.begin(), itrEnd = maLevels.end();
+    for (; itr != itrEnd; ++itr)
     {
         SCSIZE nPos = itr->first;
+        if (nPos >= mnEndPos)
+        {
+            // Don't go beyond the max allowed position.
+            DBG_ASSERT(aOutlineStack.empty(), "XclImpOutlineBuffer::MakeScOutline: outline stack not empty but expected to be.");
+            break;
+        }
         sal_uInt8 nLevel = itr->second;
         sal_uInt8 nCurLevel = static_cast<sal_uInt8>(aOutlineStack.size());
         if (nLevel > nCurLevel)
diff --git a/sc/source/filter/inc/otlnbuff.hxx b/sc/source/filter/inc/otlnbuff.hxx
index dd4d0eb..236e013 100644
--- a/sc/source/filter/inc/otlnbuff.hxx
+++ b/sc/source/filter/inc/otlnbuff.hxx
@@ -52,6 +52,7 @@ private:
     OutlineLevels       maLevels;
     ::std::set<SCSIZE>  maCollapsedPosSet;
     ScOutlineArray*     mpOutlineArray;
+    SCSIZE              mnEndPos;
     sal_uInt8           mnMaxLevel;
     bool                mbButtonAfter:1;
 };


More information about the Libreoffice-commits mailing list