[Libreoffice-commits] .: sc/source

Caolán McNamara caolan at kemper.freedesktop.org
Tue Oct 18 02:34:55 PDT 2011


 sc/source/filter/excel/impop.cxx    |    2 +-
 sc/source/filter/excel/xichart.cxx  |   10 ++++++++--
 sc/source/filter/excel/xiescher.cxx |   21 +++++++++++++--------
 sc/source/ui/unoobj/chart2uno.cxx   |   13 ++++++++++---
 4 files changed, 32 insertions(+), 14 deletions(-)

New commits:
commit 5f3a31f6f5a0271a5d2d04852e88a66672027bd1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Oct 18 10:32:38 2011 +0100

    survive some fuzz

diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index d98376f..7892776 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -200,7 +200,7 @@ sal_uInt16 ImportExcel::ReadXFIndex( bool bBiff2 )
     sal_uInt16 nXFIdx = 0;
     if( bBiff2 )
     {
-        sal_uInt8 nXFIdx2;
+        sal_uInt8 nXFIdx2 = 0;
         maStrm >> nXFIdx2;
         maStrm.Ignore( 2 );
         nXFIdx = nXFIdx2 & 0x3F;
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 36c0fe4..0e9f8fa 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -3348,8 +3348,10 @@ Reference< XAxis > XclImpChAxis::CreateAxis( const XclImpChTypeGroup& rTypeGroup
         {
             case cssc2::AxisType::CATEGORY:
             case cssc2::AxisType::SERIES:
+                OSL_ENSURE( mxLabelRange, "Missing Label Range" );
                 // #i71684# radar charts have reversed rotation direction
-                mxLabelRange->Convert( aAxisProp, aScaleData, rTypeInfo.meTypeCateg == EXC_CHTYPECATEG_RADAR );
+                if (mxLabelRange)
+                    mxLabelRange->Convert( aAxisProp, aScaleData, rTypeInfo.meTypeCateg == EXC_CHTYPECATEG_RADAR );
             break;
             case cssc2::AxisType::REALNUMBER:
             case cssc2::AxisType::PERCENT:
@@ -3401,7 +3403,11 @@ void XclImpChAxis::ConvertWall( ScfPropertySet& rPropSet ) const
 void XclImpChAxis::ConvertAxisPosition( ScfPropertySet& rPropSet, const XclImpChTypeGroup& rTypeGroup ) const
 {
     if( ((GetAxisType() == EXC_CHAXIS_X) && rTypeGroup.GetTypeInfo().mbCategoryAxis) || (GetAxisType() == EXC_CHAXIS_Z) )
-        mxLabelRange->ConvertAxisPosition( rPropSet, rTypeGroup.Is3dChart() );
+    {
+        OSL_ENSURE( mxLabelRange, "Missing Label Range" );
+        if (mxLabelRange)
+            mxLabelRange->ConvertAxisPosition( rPropSet, rTypeGroup.Is3dChart() );
+    }
     else
         mxValueRange->ConvertAxisPosition( rPropSet );
 }
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 2d88855..72af124 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -290,7 +290,7 @@ XclImpDrawObjRef XclImpDrawObjBase::ReadObj5( const XclImpRoot& rRoot, XclImpStr
 
     if( rStrm.GetRecLeft() >= 34 )
     {
-        sal_uInt16 nObjType;
+        sal_uInt16 nObjType(EXC_OBJTYPE_UNKNOWN);
         rStrm.Ignore( 4 );
         rStrm >> nObjType;
         switch( nObjType )
@@ -322,8 +322,13 @@ XclImpDrawObjRef XclImpDrawObjBase::ReadObj5( const XclImpRoot& rRoot, XclImpStr
         }
     }
 
-    xDrawObj->mnTab = rRoot.GetCurrScTab();
-    xDrawObj->ImplReadObj5( rStrm );
+    OSL_ENSURE(xDrawObj, "object import failed");
+
+    if (xDrawObj)
+    {
+        xDrawObj->mnTab = rRoot.GetCurrScTab();
+        xDrawObj->ImplReadObj5( rStrm );
+    }
     return xDrawObj;
 }
 
@@ -1664,7 +1669,7 @@ void XclImpChartObj::DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObjec
             mxChart->Convert( xModel, rDffConv, xPersist->getEntryName(), rSdrObj.GetLogicRect() );
             xPersist->storeOwn();
         }
-        catch( Exception& )
+        catch( const Exception& )
         {
         }
     }
@@ -3310,7 +3315,7 @@ SdrObject* XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxObj,
             }
         }
     }
-    catch( Exception& )
+    catch( const Exception& )
     {
     }
 
@@ -3349,7 +3354,7 @@ SdrObject* XclImpDffConverter::CreateSdrObject( const XclImpPictureObj& rPicObj,
                      }
                 }
             }
-            catch( Exception& )
+            catch( const Exception& )
             {
             }
         }
@@ -3540,7 +3545,7 @@ sal_Bool XclImpDffConverter::InsertControl( const Reference< XFormComponent >& r
         if( pxShape ) *pxShape = xShape;
         return sal_True;
     }
-    catch( Exception& )
+    catch( const Exception& )
     {
         OSL_FAIL( "XclImpDffConverter::InsertControl - cannot create form control" );
     }
@@ -3712,7 +3717,7 @@ void XclImpDffConverter::InitControlForm()
             xFormsNC->insertByName( maStdFormName, Any( rConvData.mxCtrlForm ) );
         }
     }
-    catch( Exception& )
+    catch( const Exception& )
     {
     }
 }
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 04c1537..757edb6 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -920,7 +920,10 @@ public:
             mpRangeStr->append(mcRangeSep);
 
         ScTokenRef aStart, aEnd;
-        splitRangeToken(rToken, aStart, aEnd);
+        bool bValidToken = splitRangeToken(rToken, aStart, aEnd);
+        OSL_ENSURE(bValidToken, "invalid token");
+        if (!bValidToken)
+            return;
         ScCompiler aCompiler(mpDoc, ScAddress(0,0,0));
         aCompiler.SetGrammar(FormulaGrammar::GRAM_ENGLISH);
         {
@@ -944,10 +947,13 @@ public:
 private:
     Tokens2RangeStringXML(); // disabled
 
-    void splitRangeToken(const ScTokenRef& pToken, ScTokenRef& rStart, ScTokenRef& rEnd) const
+    bool splitRangeToken(const ScTokenRef& pToken, ScTokenRef& rStart, ScTokenRef& rEnd) const
     {
         ScComplexRefData aData;
-        ScRefTokenHelper::getDoubleRefDataFromToken(aData, pToken);
+        bool bIsRefToken = ScRefTokenHelper::getDoubleRefDataFromToken(aData, pToken);
+        OSL_ENSURE(bIsRefToken, "invalid token");
+        if (!bIsRefToken)
+            return false;
         bool bExternal = ScRefTokenHelper::isExternalRef(pToken);
         sal_uInt16 nFileId = bExternal ? pToken->GetIndex() : 0;
         String aTabName = bExternal ? pToken->GetString() : String();
@@ -968,6 +974,7 @@ private:
             rEnd.reset(new ScExternalSingleRefToken(nFileId, aTabName, aData.Ref2));
         else
             rEnd.reset(new ScSingleRefToken(aData.Ref2));
+        return true;
     }
 
     void setRelative(ScSingleRefData& rData) const


More information about the Libreoffice-commits mailing list