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

Caolán McNamara caolanm at redhat.com
Mon Nov 17 12:26:22 PST 2014


 chart2/source/controller/main/SelectionHelper.cxx |    9 ++-------
 sc/source/filter/excel/xistyle.cxx                |   12 +++++++++---
 2 files changed, 11 insertions(+), 10 deletions(-)

New commits:
commit 96b524cdd639b57c875eada551e267654f2a83fc
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Nov 17 17:03:15 2014 +0000

    coverity#1242891 Untrusted loop bound
    
    Change-Id: I5859cef0fa6b9c49225c5d7b073bcbc521734854

diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index 7349a8e..446b283 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -150,8 +150,15 @@ void XclImpPalette::ReadPalette( XclImpStream& rStrm )
 {
     sal_uInt16 nCount;
     rStrm >> nCount;
-    OSL_ENSURE( rStrm.GetRecLeft() == static_cast< sal_Size >( 4 * nCount ),
-        "XclImpPalette::ReadPalette - size mismatch" );
+
+    const size_t nMinRecordSize = 4;
+    const size_t nMaxRecords = rStrm.GetRecLeft() / nMinRecordSize;
+    if (nCount > nMaxRecords)
+    {
+        SAL_WARN("sc", "Parsing error: " << nMaxRecords <<
+                 " max possible entries, but " << nCount << " claimed, truncating");
+        nCount = nMaxRecords;
+    }
 
     maColorTable.resize( nCount );
     Color aColor;
@@ -164,7 +171,6 @@ void XclImpPalette::ReadPalette( XclImpStream& rStrm )
 }
 
 // FONT record - font information =============================================
-
 XclImpFont::XclImpFont( const XclImpRoot& rRoot ) :
     XclImpRoot( rRoot ),
     mbHasCharSet( false ),
commit 5d0da4db5a8c7a76f83c4db60e4577bf2202ed9f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Nov 17 16:39:03 2014 +0000

    coverity#1242824 Unused value
    
    Change-Id: I5f53e538f8f76c337cda8b90fcf4ed717ed2476e

diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx
index 8389fe4e..ee54fc8 100644
--- a/chart2/source/controller/main/SelectionHelper.cxx
+++ b/chart2/source/controller/main/SelectionHelper.cxx
@@ -172,13 +172,12 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper*
         //bAllowMultiClickSelectionChange==true -> a second click on the same object can lead to a changed selection (e.g. series -> single data point)
 
         //get object to select:
-        SdrObject* pNewObj = 0;
         {
             m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
 
             //the search for the object to select starts with the hit object deepest in the grouping hierarchy (a leaf in the tree)
             //further we travel along the grouping hierarchy from child to parent
-            pNewObj = pDrawViewWrapper->getHitObject(rMousePos);
+            SdrObject* pNewObj = pDrawViewWrapper->getHitObject(rMousePos);
             m_aSelectedOID = ObjectIdentifier( lcl_getObjectName( pNewObj ) );//name of pNewObj
 
             //ignore handle only objects for hit test
@@ -207,7 +206,6 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper*
                         //if a sibling of the last selected object is clicked don't go up further
                         break;
                     }
-                    SdrObject*    pLastChild     = pNewObj;
                     ObjectIdentifier aLastChild = m_aSelectedOID;
                     if ( !SelectionHelper::findNamedParent( pNewObj, m_aSelectedOID, false ) )
                     {
@@ -220,17 +218,15 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper*
                     {
                         if( bAllowMultiClickSelectionChange )
                         {
-                            pNewObj  = pLastChild;
                             m_aSelectedOID = aLastChild;
                         }
                         else
                             m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = aLastChild;
-
                         break;
                     }
                 }
 
-                OSL_ENSURE( pNewObj && m_aSelectedOID.isValid(), "somehow lost selected object" );
+                OSL_ENSURE(m_aSelectedOID.isValid(), "somehow lost selected object");
             }
             else
             {
@@ -281,7 +277,6 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper*
                         if( pDrawViewWrapper->IsObjectHit( pLegend, rMousePos ) )
                         {
                             m_aSelectedOID = ObjectIdentifier( aLegendCID );
-                            pNewObj = pLegend;
                         }
                     }
                 }


More information about the Libreoffice-commits mailing list