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

Eike Rathke erack at redhat.com
Fri Oct 27 12:56:12 UTC 2017


 sc/source/filter/qpro/qproform.cxx |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

New commits:
commit b53974c1530d14eebdc561ada3ecaf8fc3b58929
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Oct 27 11:39:39 2017 +0200

    ofz#2947 check for input stream end
    
    Change-Id: I48d43a358e9a8e37a3c862c310a2e4b2e756f536
    Reviewed-on: https://gerrit.libreoffice.org/43937
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx
index 946d4ac05860..73da364969c9 100644
--- a/sc/source/filter/qpro/qproform.cxx
+++ b/sc/source/filter/qpro/qproform.cxx
@@ -171,6 +171,14 @@ do { \
     nRef-=amt; \
 } while(false)
 
+#define SAFEREAD_OR_BREAK( aStream, i, nRef, eRet, ret ) \
+    if (!aStream.good()) \
+    { \
+        i = nRef-1;     /* will be incremented at end of while */ \
+        eRet = ret; \
+        break;          /* switch */ \
+    }
+
 ConvErr QProToSc::Convert( const ScTokenArray*& pArray )
 {
     sal_uInt8 nFmla[ nBufSize ], nArg;
@@ -244,6 +252,7 @@ ConvErr QProToSc::Convert( const ScTokenArray*& pArray )
     nDLLCount = 0;
     nArgCount = 0;
     nStringCount = 0;
+    ConvErr eRet = ConvErr::OK;
 
     while( i < nRef && ( nFmla[ i ] != 0x03 ) )
     {
@@ -297,14 +306,17 @@ ConvErr QProToSc::Convert( const ScTokenArray*& pArray )
 
             case FT_Cref : // Single cell reference
                 maIn.ReadUInt16( nNote ).ReadSChar( nCol ).ReadSChar( nPage ).ReadUInt16( nRelBits );
+                SAFEREAD_OR_BREAK( maIn, i, nRef, eRet, ConvErr::Count);
                 ReadSRD( aSRD, nPage, nCol, nRelBits );
                 aStack << aPool.Store( aSRD );
                 break;
 
             case FT_Range: // Block reference
                 maIn.ReadUInt16( nNote ).ReadSChar( nCol ).ReadSChar( nPage ).ReadUInt16( nRelBits );
+                SAFEREAD_OR_BREAK( maIn, i, nRef, eRet, ConvErr::Count);
                 ReadSRD( aCRD.Ref1, nPage, nCol, nRelBits );
                 maIn.ReadSChar( nCol ).ReadSChar( nPage ).ReadUInt16( nRelBits );
+                SAFEREAD_OR_BREAK( maIn, i, nRef, eRet, ConvErr::Count);
                 ReadSRD( aCRD.Ref2, nPage, nCol, nRelBits );
                 // Sheet name of second corner is not displayed if identical
                 if (aCRD.Ref1.IsFlag3D() && aCRD.Ref1.Tab() == aCRD.Ref2.Tab() &&
@@ -367,7 +379,7 @@ ConvErr QProToSc::Convert( const ScTokenArray*& pArray )
         i++;
     }
     pArray = aPool[ aStack.Get() ];
-    return ConvErr::OK;
+    return eRet;
 }
 
 static const struct


More information about the Libreoffice-commits mailing list