[Libreoffice-commits] core.git: 13 commits - chart2/source editeng/source formula/source framework/source sc/source sfx2/source starmath/source sw/source

Caolán McNamara caolanm at redhat.com
Sun Feb 9 07:54:31 PST 2014


 chart2/source/view/main/DummyXShape.cxx              |   13 +++---
 editeng/source/editeng/impedit2.cxx                  |    6 --
 editeng/source/editeng/impedit3.cxx                  |    4 +
 editeng/source/editeng/impedit4.cxx                  |    4 -
 formula/source/ui/dlg/formula.cxx                    |    2 
 framework/source/services/autorecovery.cxx           |    2 
 framework/source/uielement/controlmenucontroller.cxx |    6 +-
 sc/source/core/tool/compiler.cxx                     |    2 
 sc/source/core/tool/tokenstringcontext.cxx           |    3 -
 sfx2/source/control/bindings.cxx                     |    2 
 starmath/source/accessibility.cxx                    |    5 +-
 sw/source/ui/shells/drwtxtex.cxx                     |   30 ++++++++------
 sw/source/ui/shells/txtattr.cxx                      |   40 +++++++++++--------
 13 files changed, 69 insertions(+), 50 deletions(-)

New commits:
commit a6b41b0c1460d3c9516b8d4e4d88abdc4fdb7ea2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:53:22 2014 +0000

    coverity#1169825 Dereference after null check
    
    Change-Id: I74df9084f46e38901b6682b892fa7d0f71d72572

diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 0a00747..905fcfe 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -1917,7 +1917,7 @@ void SfxBindings::ClearCache_Impl( sal_uInt16 nSlotId )
 {
     SfxStateCache* pCache = GetStateCache(nSlotId);
     if (!pCache)
-        return
+        return;
     pCache->ClearCache();
 }
 
commit 57e0062f2043f7a0382db5f4d01c6c70ca8aca46
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:50:10 2014 +0000

    coverity#1169826 Dereference after null check
    
    Change-Id: Ie431672b5a6ba1d613ae1cb9e48fa6d1db6a6b4a

diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx
index 3a542b3..08723c8 100644
--- a/framework/source/uielement/controlmenucontroller.cxx
+++ b/framework/source/uielement/controlmenucontroller.cxx
@@ -264,7 +264,7 @@ void ControlMenuController::updateImagesPopupMenu( PopupMenu* pPopupMenu )
     if ( pResMgr->IsAvailable( aResId ))
     {
         ImageList aImageList( aResId );
-      for ( sal_uInt32 i=0; i < sizeof(nConvertSlots)/sizeof(nConvertSlots[0]); ++i )
+        for ( sal_uInt32 i=0; i < sizeof(nConvertSlots)/sizeof(nConvertSlots[0]); ++i )
         {
             // das entsprechende Image dran
             if ( m_bShowMenuImages )
@@ -411,9 +411,11 @@ void ControlMenuController::impl_setPopupMenu()
             ResId aResId( RID_FMSHELL_CONVERSIONMENU, *pResMgr );
             aResId.SetRT( RSC_MENU );
             if ( pResMgr->IsAvailable( aResId ))
+            {
                 m_pResPopupMenu = new PopupMenu( aResId );
+                updateImagesPopupMenu( m_pResPopupMenu );
+            }
 
-            updateImagesPopupMenu( m_pResPopupMenu );
             delete pResMgr;
         }
     } // if ( m_pResPopupMenu == 0 )
commit daf4fb951bf8493b3425f24beb7eb1a6c36f838a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:43:56 2014 +0000

    coverity#1169827 Explicit null dereferenced
    
    Change-Id: Iaca51f3795341c1c834772abba340501b3fc60a3

diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index e124021..8bfefb3 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2254,6 +2254,10 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos
     }
 
     DBG_ASSERT( pTextPortion, "Position outside the area!" );
+
+    if (!pTextPortion)
+        return 0;
+
     DBG_ASSERT( pTextPortion->GetKind() == PORTIONKIND_TEXT, "SplitTextPortion: No TextPortion!" );
 
     sal_Int32 nOverlapp = nTmpPos - nPos;
commit ecfeb72252c18c7fc94170e19a1ca6aba4116e72
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:41:54 2014 +0000

    coverity#1169828 Explicit null dereferenced
    
    Change-Id: Iad58bc1f5295bdaaff4ba17e70cb3aa4d5fc5aca

diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index eb1e366..514668c 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -3982,12 +3982,10 @@ long ImpEditEngine::GetXPos(
                     if ( pPortion->GetExtraInfos()->nAsianCompressionTypes & CHAR_PUNCTUATIONRIGHT )
                     {
                         sal_uInt8 nType = GetCharTypeForCompression( pParaPortion->GetNode()->GetChar( nIndex ) );
-                        if ( nType == CHAR_PUNCTUATIONRIGHT )
+                        if ( nType == CHAR_PUNCTUATIONRIGHT && !pLine->GetCharPosArray().empty() )
                         {
                             sal_Int32 n = nIndex - nTextPortionStart;
-                            const sal_Int32* pDXArray = NULL;
-                            if (!pLine->GetCharPosArray().empty())
-                                pDXArray = &pLine->GetCharPosArray()[0]+( nTextPortionStart-pLine->GetStart() );
+                            const sal_Int32* pDXArray = &pLine->GetCharPosArray()[0]+( nTextPortionStart-pLine->GetStart() );
                             sal_Int32 nCharWidth = ( ( (n+1) < pPortion->GetLen() ) ? pDXArray[n] : pPortion->GetSize().Width() )
                                                             - ( n ? pDXArray[n-1] : 0 );
                             if ( (n+1) < pPortion->GetLen() )
commit b8ba31a4028d8af77111b6a078f3ae0390db734b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:37:31 2014 +0000

    coverity#1169832 Using invalid iterator
    
    Change-Id: I40b732f42f48c3d72fed4cee0241a5c6a6cb31a2

diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index c514424..8eb97e3 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -948,14 +948,15 @@ void DummyXShapes::remove( const uno::Reference< drawing::XShape>& xShape )
     throw(uno::RuntimeException)
 {
     std::vector< uno::Reference<drawing::XShape> >::iterator itr = std::find(maUNOShapes.begin(), maUNOShapes.end(), xShape);
-
-    DummyXShape* pChild = dynamic_cast<DummyXShape*>((*itr).get());
-    std::vector< DummyXShape* >::iterator itrShape = std::find(maShapes.begin(), maShapes.end(), pChild);
-    if(itrShape != maShapes.end())
-        maShapes.erase(itrShape);
-
     if(itr != maUNOShapes.end())
+    {
+        DummyXShape* pChild = dynamic_cast<DummyXShape*>((*itr).get());
+        std::vector< DummyXShape* >::iterator itrShape = std::find(maShapes.begin(), maShapes.end(), pChild);
+        if(itrShape != maShapes.end())
+            maShapes.erase(itrShape);
+
         maUNOShapes.erase(itr);
+    }
 }
 
 uno::Type DummyXShapes::getElementType()
commit 3efa186565eed2f201e604f270134c3a27cfc5b2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:35:22 2014 +0000

    coverity#1169834 Mixing enum types
    
    Change-Id: Icd0735a60cb5986af85917e37efcfae591bfe3e1

diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 7a61810..71512d2 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1007,10 +1007,10 @@ EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool
 {
     EditTextObject* pTxtObj = new EditTextObject(pPool);
     pTxtObj->SetVertical( IsVertical() );
-    MapUnit eMapUnit = (MapUnit)aEditDoc.GetItemPool().GetMetric( DEF_METRIC );
+    SfxMapUnit eMapUnit = aEditDoc.GetItemPool().GetMetric( DEF_METRIC );
     pTxtObj->mpImpl->SetMetric( (sal_uInt16) eMapUnit );
     if ( pTxtObj->mpImpl->IsOwnerOfPool() )
-        pTxtObj->mpImpl->GetPool()->SetDefaultMetric( (SfxMapUnit) eMapUnit );
+        pTxtObj->mpImpl->GetPool()->SetDefaultMetric( eMapUnit );
 
     sal_Int32 nStartNode, nEndNode;
     sal_Int32 nTextPortions = 0;
commit 0b9f65d05cc22da96eb27f6ccd040f8a27848594
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:30:28 2014 +0000

    coverity#1169835 Improper use of negative value
    
    Change-Id: I73b9ea3f1da05c8ddfd8e0b2da526b65dc1891bb

diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 257de49..32a52ed 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -499,7 +499,7 @@ sal_Int32 FormulaDlg_Impl::GetFunctionPos(sal_Int32 nPos)
             if( eOp == m_aSpecialOpCodes[sheet::FormulaMapGroupSpecialOffset::PUSH].Token.OpCode ||
                 eOp == m_aSpecialOpCodes[sheet::FormulaMapGroupSpecialOffset::SPACES].Token.OpCode )
             {
-                const sal_Int32 n1 = aFormString.indexOf(sep, nTokPos);
+                const sal_Int32 n1 = nTokPos < 0 ? -1 : aFormString.indexOf(sep, nTokPos);
                 const sal_Int32 n2 = nTokPos < 0 ? -1 : aFormString.indexOf(')',nTokPos);
                 sal_Int32 nXXX = nTokPos;
                 if( n1 < n2 )
commit abd0ad882997dd980c483c687537971a948e81c5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:28:21 2014 +0000

    coverity#1169836 Dereference null return value
    
    Change-Id: I402ceff13b2f081734151b8597c0d79ecebd6f52

diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index 43dc44d..2d6becb 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -1364,7 +1364,10 @@ sal_Int32 SmTextForwarder::GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const
 void SmTextForwarder::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nPara, sal_Int32 nLine ) const
 {
     EditEngine *pEditEngine = rEditAcc.GetEditEngine();
-    pEditEngine->GetLineBoundaries(rStart, rEnd, nPara, nLine);
+    if (pEditEngine)
+        pEditEngine->GetLineBoundaries(rStart, rEnd, nPara, nLine);
+    else
+        rStart = rEnd = 0;
 }
 
 sal_Int32 SmTextForwarder::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const
commit b2f727aec7cfe94968fb4dec95eaa78b71193bff
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:25:31 2014 +0000

    coverity#1169837 Dereference null return value
    
    Change-Id: I36d3df9483437a008ff04e254a20b85f2ac042e4

diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx
index 43b0dfb..0b5a0b9 100644
--- a/sw/source/ui/shells/drwtxtex.cxx
+++ b/sw/source/ui/shells/drwtxtex.cxx
@@ -562,17 +562,23 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
             aSetItem.GetItemSet().Put( aEditAttr, false );
 
             sal_uInt16 nScriptTypes = pOLV->GetSelectedScriptType();
-            SvxFontHeightItem aSize( *static_cast<const SvxFontHeightItem*>( aSetItem.GetItemOfScript( nScriptTypes ) ) );
-            sal_uInt32 nSize = aSize.GetHeight();
+            const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>( aSetItem.GetItemOfScript( nScriptTypes ) ) );
 
-            if( nSlot == FN_GROW_FONT_SIZE && ( nSize += nFontInc ) > nFontMaxSz )
-                nSize = nFontMaxSz;
-            else if( nSlot == FN_SHRINK_FONT_SIZE && ( nSize -= nFontInc ) < nFontInc )
-                nSize = nFontInc;
+            if (pSize)
+            {
+                SvxFontHeightItem aSize(*pSize);
+
+                sal_uInt32 nSize = aSize.GetHeight();
+
+                if( nSlot == FN_GROW_FONT_SIZE && ( nSize += nFontInc ) > nFontMaxSz )
+                    nSize = nFontMaxSz;
+                else if( nSlot == FN_SHRINK_FONT_SIZE && ( nSize -= nFontInc ) < nFontInc )
+                    nSize = nFontInc;
 
-            aSize.SetHeight( nSize );
-            aSetItem.PutItemForScriptType( nScriptTypes, aSize );
-            aNewAttr.Put( aSetItem.GetItemSet() );
+                aSize.SetHeight( nSize );
+                aSetItem.PutItemForScriptType( nScriptTypes, aSize );
+                aNewAttr.Put( aSetItem.GetItemSet() );
+            }
         }
         break;
 
@@ -925,13 +931,13 @@ void SwDrawTextShell::GetDrawTxtCtrlState(SfxItemSet& rSet)
 
                 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, *pEditPool );
                 aSetItem.GetItemSet().Put( aEditAttr, false );
-                const SvxFontHeightItem* aSize( static_cast<const SvxFontHeightItem*>( aSetItem.GetItemOfScript( nScriptType ) ) );
+                const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>( aSetItem.GetItemOfScript( nScriptType ) ) );
 
-                if( !aSize )
+                if( !pSize )
                     rSet.DisableItem( nSlotId );
                 else
                 {
-                    sal_uInt32 nSize = aSize->GetHeight();
+                    sal_uInt32 nSize = pSize->GetHeight();
                     if( nSize == nFontMaxSz )
                         rSet.DisableItem( FN_GROW_FONT_SIZE );
                     else if( nSize == nFontInc )
commit 39ecb2470c21c842559e8ac2c4d78c8e1e3cf880
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:22:45 2014 +0000

    coverity#1169838 Dereference null return value
    
    Change-Id: I6e8f83569fdb1ee7d7f513e065e6233aecf140f4

diff --git a/sw/source/ui/shells/txtattr.cxx b/sw/source/ui/shells/txtattr.cxx
index 1451982..c52aaa2 100644
--- a/sw/source/ui/shells/txtattr.cxx
+++ b/sw/source/ui/shells/txtattr.cxx
@@ -226,22 +226,30 @@ void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq)
             SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() );
 
             sal_uInt16 nScriptTypes = rWrtSh.GetScriptType();
-            SvxFontHeightItem aSize( *static_cast<const SvxFontHeightItem*>( aSetItem.GetItemOfScript( nScriptTypes ) ) );
-            sal_uInt32 nSize = aSize.GetHeight();
 
-            if ( nSlot == FN_GROW_FONT_SIZE && ( nSize += nFontInc ) > nFontMaxSz )
-                nSize = nFontMaxSz;
-            else if ( nSlot == FN_SHRINK_FONT_SIZE && ( nSize -= nFontInc ) < nFontInc )
-                nSize = nFontInc;
+            const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
+                                        aSetItem.GetItemOfScript( nScriptTypes ) ) );
 
-            aSize.SetHeight( nSize );
-            aSetItem.PutItemForScriptType( nScriptTypes, aSize );
-            aAttrSet.Put( aSetItem.GetItemSet() );
+            if (pSize)
+            {
+                SvxFontHeightItem aSize(*pSize);
 
-            if( pColl )
-                pColl->SetFmtAttr( aAttrSet );
-            else
-                rWrtSh.SetAttrSet( aAttrSet );
+                sal_uInt32 nSize = aSize.GetHeight();
+
+                if ( nSlot == FN_GROW_FONT_SIZE && ( nSize += nFontInc ) > nFontMaxSz )
+                    nSize = nFontMaxSz;
+                else if ( nSlot == FN_SHRINK_FONT_SIZE && ( nSize -= nFontInc ) < nFontInc )
+                    nSize = nFontInc;
+
+                aSize.SetHeight( nSize );
+                aSetItem.PutItemForScriptType( nScriptTypes, aSize );
+                aAttrSet.Put( aSetItem.GetItemSet() );
+
+                if( pColl )
+                    pColl->SetFmtAttr( aAttrSet );
+                else
+                    rWrtSh.SetAttrSet( aAttrSet );
+            }
 
             rReq.Done();
         }
@@ -598,14 +606,14 @@ void SwTextShell::GetAttrState(SfxItemSet &rSet)
                 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT,
                                             *rSet.GetPool() );
                 aSetItem.GetItemSet().Put( aCoreSet, false );
-                const SvxFontHeightItem* aSize( static_cast<const SvxFontHeightItem*>(
+                const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
                                             aSetItem.GetItemOfScript( rSh.GetScriptType() ) ) );
 
-                if( !aSize )
+                if( !pSize )
                     rSet.DisableItem( nSlot );
                 else
                 {
-                    sal_uInt32 nSize = aSize->GetHeight();
+                    sal_uInt32 nSize = pSize->GetHeight();
                     if( nSize == nFontMaxSz )
                         rSet.DisableItem( FN_GROW_FONT_SIZE );
                     else if( nSize == nFontInc )
commit 22e59ea977247b7090a04c872157aad5113314a9
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:17:17 2014 +0000

    coverity#1169839 Unintentional integer overflow
    
    Change-Id: I21d7962043e26e8a7973dd2f9305dd6a48f3db4a

diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index 7aa43e1..95362d7 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -2422,7 +2422,7 @@ void AutoRecovery::implts_updateTimer()
        )
         return;
 
-    sal_uLong nMilliSeconds = 0;
+    sal_Int32 nMilliSeconds = 0;
     if (m_eTimerType == AutoRecovery::E_NORMAL_AUTOSAVE_INTERVALL)
     {
         nMilliSeconds = (m_nAutoSaveTimeIntervall*60000); // [min] => 60.000 ms
commit 6e4fcc7d756422a5b0cec60a6e23a764e40155f9
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:15:10 2014 +0000

    coverity#1169843 Dereference before null check
    
    Change-Id: I9e13a63ce78f317b35a7a374a2fd1ed699915944

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index f8d00f1..eae1856 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1536,7 +1536,7 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos,
     mbRewind(false),
     maTabNames(rCxt.getTabNames())
 {
-    nMaxTab = pDoc ? pDoc->GetTableCount() - 1 : 0;
+    nMaxTab = pDoc->GetTableCount() - 1;
     SetGrammar(rCxt.getGrammar());
 }
 
commit 0bfaf41a17d5f3209db96b35a5d53fe8b1a19c0e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 9 15:14:04 2014 +0000

    coverity#1169844 Dereference before null check
    
    Change-Id: Idc61581fd8725c0c154cfa2d9912c513907ddc01

diff --git a/sc/source/core/tool/tokenstringcontext.cxx b/sc/source/core/tool/tokenstringcontext.cxx
index 203d36a..841867e 100644
--- a/sc/source/core/tool/tokenstringcontext.cxx
+++ b/sc/source/core/tool/tokenstringcontext.cxx
@@ -108,9 +108,6 @@ TokenStringContext::TokenStringContext( const ScDocument* pDoc, formula::Formula
 CompileFormulaContext::CompileFormulaContext( ScDocument* pDoc ) :
     mpDoc(pDoc), meGram(pDoc->GetGrammar())
 {
-    if (!pDoc)
-        return;
-
     updateTabNames();
 }
 


More information about the Libreoffice-commits mailing list