[Libreoffice-commits] core.git: 14 commits - basic/source connectivity/source cui/source dbaccess/source filter/source sfx2/source xmloff/source

Caolán McNamara caolanm at redhat.com
Thu Oct 1 06:41:57 PDT 2015


 basic/source/classes/sbunoobj.cxx                   |    7 ++---
 connectivity/source/drivers/dbase/DIndexIter.cxx    |    2 -
 cui/source/customize/acccfg.cxx                     |    2 -
 dbaccess/source/ui/dlg/dbadmin.cxx                  |    8 ++---
 filter/source/graphicfilter/ipict/ipict.cxx         |    4 +-
 filter/source/pdf/pdfexport.cxx                     |    8 ++---
 sfx2/source/view/viewfrm.cxx                        |    4 +-
 xmloff/source/draw/ximpshap.cxx                     |    2 -
 xmloff/source/text/XMLTextFrameHyperlinkContext.cxx |    6 ++--
 xmloff/source/text/txtparaimphint.hxx               |   27 ++++++++------------
 10 files changed, 33 insertions(+), 37 deletions(-)

New commits:
commit 326c93feaa89383ef10e5a9878bb2096c895ed91
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:30:59 2015 +0100

    coverity#1242658 Untrusted loop bound
    
    Change-Id: Idc3b3ce1174537039ce613e2f84f857e94299faa

diff --git a/filter/source/graphicfilter/ipict/ipict.cxx b/filter/source/graphicfilter/ipict/ipict.cxx
index d926079..53b1a09 100644
--- a/filter/source/graphicfilter/ipict/ipict.cxx
+++ b/filter/source/graphicfilter/ipict/ipict.cxx
@@ -835,7 +835,7 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
             BITMAPERROR;
 
         if ( nRowBytes < 8 || nPackType == 1 ) {
-            if (pPict->remainingSize() < sizeof(sal_uInt8) * nHeight * nRowBytes)
+            if (nHeight > pPict->remainingSize() / (sizeof(sal_uInt8) * nRowBytes))
                 BITMAPERROR;
         }
 
@@ -908,7 +908,7 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
             BITMAPERROR;
 
         if ( nRowBytes < 8 || nPackType == 1 ) {
-            if (pPict->remainingSize() < sizeof(sal_uInt16) * nHeight * nWidth)
+            if (nHeight > pPict->remainingSize() / (sizeof(sal_uInt16) * nWidth))
                 BITMAPERROR;
         }
 
commit d176c0f3040743d470976bf99cbcc5a7b864e50e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:24:46 2015 +0100

    coverity#1325256 Dereference null return value
    
    Change-Id: If4ae66b8f6aef172c5e616d94f9d804b72d3a774

diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index e2498e7..33c9623 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -2556,9 +2556,9 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro )
             if ( pBasic )
             {
                 SbModule* pModule = pBasic->FindModule( aModuleName );
-                if ( pModule )
+                SbMethod* pMethod = pModule ? static_cast<SbMethod*>(pModule->GetMethods()->Find(aMacroName, SbxCLASS_METHOD)) : nullptr;
+                if (pMethod)
                 {
-                    SbMethod* pMethod = static_cast<SbMethod*>(pModule->GetMethods()->Find( aMacroName, SbxCLASS_METHOD ));
                     aOUSource = pModule->GetSource32();
                     sal_uInt16 nStart, nEnd;
                     pMethod->GetLineRange( nStart, nEnd );
commit 5e6d41ddcf705fd71129c07b1c990d0f99f384b6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:21:51 2015 +0100

    coverity#735690 Unchecked dynamic_cast
    
    and
    
    coverity#735689 Unchecked dynamic_cast
    
    Change-Id: I1181e21146972c7c01b0a421d3c1c4ecc3d7e75a

diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx
index 0522cb3..62c7668 100644
--- a/dbaccess/source/ui/dlg/dbadmin.cxx
+++ b/dbaccess/source/ui/dlg/dbadmin.cxx
@@ -109,8 +109,8 @@ void ODbAdminDialog::impl_selectDataSource(const css::uno::Any& _aDataSourceName
     Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
     impl_resetPages( xDatasource );
 
-    const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const DbuTypeCollectionItem*>( getOutputSet()->GetItem(DSID_TYPECOLLECTION) );
-    ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection();
+    const DbuTypeCollectionItem& rCollectionItem = dynamic_cast<const DbuTypeCollectionItem&>(*getOutputSet()->GetItem(DSID_TYPECOLLECTION));
+    ::dbaccess::ODsnTypeCollection* pCollection = rCollectionItem.getCollection();
     ::dbaccess::DATASOURCE_TYPE eType = pCollection->determineType(getDatasourceType(*getOutputSet()));
 
     // and insert the new ones
@@ -200,8 +200,8 @@ void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasou
 
     // special case: MySQL Native does not have the generic "advanced" page
 
-    const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const DbuTypeCollectionItem*>( getOutputSet()->GetItem(DSID_TYPECOLLECTION) );
-    ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection();
+    const DbuTypeCollectionItem& rCollectionItem = dynamic_cast<const DbuTypeCollectionItem&>(*getOutputSet()->GetItem(DSID_TYPECOLLECTION));
+    ::dbaccess::ODsnTypeCollection* pCollection = rCollectionItem.getCollection();
     if ( pCollection->determineType(getDatasourceType( *pExampleSet )) == ::dbaccess::DST_MYSQL_NATIVE )
     {
         AddTabPage( PAGE_MYSQL_NATIVE, OUString( ModuleRes( STR_PAGETITLE_CONNECTION ) ), ODriversSettings::CreateMySQLNATIVE, NULL );
commit 6480d68afc2740d033973453767904e7876df891
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:20:34 2015 +0100

    coverity#735748 Unchecked dynamic_cast
    
    Change-Id: Id15888f32996dd2ce05bed6942ebebdb8223a85b

diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index fb7469d..eff86c9 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -184,10 +184,10 @@ bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter,
 
         if( pOut )
         {
-            vcl::PDFExtOutDevData* pPDFExtOutDevData = dynamic_cast<vcl::PDFExtOutDevData* >( pOut->GetExtOutDevData() );
             if ( nPageCount )
             {
-                pPDFExtOutDevData->SetIsExportNotesPages( bExportNotesPages );
+                vcl::PDFExtOutDevData& rPDFExtOutDevData = dynamic_cast<vcl::PDFExtOutDevData&>(*pOut->GetExtOutDevData());
+                rPDFExtOutDevData.SetIsExportNotesPages( bExportNotesPages );
 
                 sal_Int32 nCurrentPage(0);
                 StringRangeEnumerator::Iterator aIter = rRangeEnum.begin();
@@ -203,7 +203,7 @@ bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter,
                             aRenderer[ nProperty].Value >>= aPageSize;
                     }
 
-                    pPDFExtOutDevData->SetCurrentPageNumber( nCurrentPage );
+                    rPDFExtOutDevData.SetCurrentPageNumber( nCurrentPage );
 
                     GDIMetaFile                 aMtf;
                     const MapMode               aMapMode( MAP_100TH_MM );
@@ -231,7 +231,7 @@ bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter,
 
                     if( aMtf.GetActionSize() &&
                              ( !mbSkipEmptyPages || aPageSize.Width || aPageSize.Height ) )
-                        bRet = ImplExportPage( rPDFWriter, *pPDFExtOutDevData, aMtf ) || bRet;
+                        bRet = ImplExportPage(rPDFWriter, rPDFExtOutDevData, aMtf) || bRet;
 
                     pOut->Pop();
 
commit 3b4fcee7721875e31b6286875fb1328042def7e3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:18:10 2015 +0100

    coverity#1209375 Unchecked dynamic_cast
    
    Change-Id: Ib6ac44878c6f485326c16fd0224b220e86a4dc6a

diff --git a/connectivity/source/drivers/dbase/DIndexIter.cxx b/connectivity/source/drivers/dbase/DIndexIter.cxx
index 1e7d374..1d52995 100644
--- a/connectivity/source/drivers/dbase/DIndexIter.cxx
+++ b/connectivity/source/drivers/dbase/DIndexIter.cxx
@@ -132,7 +132,7 @@ ONDXKey* OIndexIterator::GetFirstKey(ONDXPage* pPage, const OOperand& rKey)
 sal_uIntPtr OIndexIterator::GetCompare(bool bFirst)
 {
     ONDXKey* pKey = NULL;
-    sal_Int32 ePredicateType = dynamic_cast<file::OOp_COMPARE*>(m_pOperator)->getPredicateType();
+    sal_Int32 ePredicateType = dynamic_cast<file::OOp_COMPARE&>(*m_pOperator).getPredicateType();
 
     if (bFirst)
     {
commit 369d1e420b8b884f4a4ee5b9141ee864bec12b8c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:17:08 2015 +0100

    coverity#1325246 Unchecked dynamic_cast
    
    Change-Id: Ifa8f9ce23c9c737d7bed9e24c9c32641d915ac76

diff --git a/xmloff/source/text/txtparaimphint.hxx b/xmloff/source/text/txtparaimphint.hxx
index 7d58e65..78b7cdd 100644
--- a/xmloff/source/text/txtparaimphint.hxx
+++ b/xmloff/source/text/txtparaimphint.hxx
@@ -230,14 +230,12 @@ public:
     {
         bool bRet = false;
         SvXMLImportContext *pContext = &xContext;
-        if( 0 != dynamic_cast<const XMLTextFrameContext*>(pContext) )
+        if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
             bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
-                dynamic_cast<const XMLTextFrameContext*>( pContext )
-                    ->GetAnchorType();
-        else if( 0 != dynamic_cast<const XMLTextFrameHyperlinkContext*>( pContext) )
+                pFrameContext->GetAnchorType();
+        else if (XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
             bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
-                dynamic_cast<const XMLTextFrameHyperlinkContext*>( pContext )
-                    ->GetAnchorType();
+                pLinkContext->GetAnchorType();
         return bRet;
     }
 };
commit 6f7e93b9488c41a2b43d897c1e2d3fb527ef3b36
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:16:08 2015 +0100

    coverity#1325247 Unchecked dynamic_cast
    
    Change-Id: I86e3387c277767018565ed0708d35682ba2de3ae

diff --git a/xmloff/source/text/txtparaimphint.hxx b/xmloff/source/text/txtparaimphint.hxx
index a447fd7..7d58e65 100644
--- a/xmloff/source/text/txtparaimphint.hxx
+++ b/xmloff/source/text/txtparaimphint.hxx
@@ -205,11 +205,10 @@ public:
     {
         css::uno::Reference < css::text::XTextContent > xTxt;
         SvXMLImportContext *pContext = &xContext;
-        if( 0 != dynamic_cast<const XMLTextFrameContext*>(pContext) )
-            xTxt = dynamic_cast< XMLTextFrameContext*>( pContext )->GetTextContent();
-        else if( 0 != dynamic_cast<const XMLTextFrameHyperlinkContext*>(pContext) )
-            xTxt = dynamic_cast< XMLTextFrameHyperlinkContext* >( pContext )
-                        ->GetTextContent();
+        if (XMLTextFrameContext *pFrameContext =  dynamic_cast<XMLTextFrameContext*>(pContext))
+            xTxt = pFrameContext->GetTextContent();
+        else if (XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
+            xTxt = pLinkContext->GetTextContent();
 
         return xTxt;
     }
@@ -219,7 +218,7 @@ public:
     {
         css::uno::Reference < css::drawing::XShape > xShape;
         SvXMLImportContext *pContext = &xContext;
-        if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext) )
+        if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
             xShape = pFrameContext->GetShape();
         else if(XMLTextFrameHyperlinkContext *pLinkContext =  dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
             xShape = pLinkContext->GetShape();
commit 40c7d2719ae2a60f849ec8cdbcb4fc0f84abbffc
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:14:51 2015 +0100

    coverity#1325248 Unchecked dynamic_cast
    
    Change-Id: Iff328c85e859cae2d99f95c3c56ba3585638dd23

diff --git a/xmloff/source/text/txtparaimphint.hxx b/xmloff/source/text/txtparaimphint.hxx
index a46ad8b..a447fd7 100644
--- a/xmloff/source/text/txtparaimphint.hxx
+++ b/xmloff/source/text/txtparaimphint.hxx
@@ -219,10 +219,10 @@ public:
     {
         css::uno::Reference < css::drawing::XShape > xShape;
         SvXMLImportContext *pContext = &xContext;
-        if( 0 != dynamic_cast<const XMLTextFrameContext*>(pContext) )
-            xShape = dynamic_cast< XMLTextFrameContext*>( pContext )->GetShape();
-        else if( 0 != dynamic_cast<const XMLTextFrameHyperlinkContext*>(pContext) )
-            xShape = dynamic_cast<XMLTextFrameHyperlinkContext*>( pContext )->GetShape();
+        if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext) )
+            xShape = pFrameContext->GetShape();
+        else if(XMLTextFrameHyperlinkContext *pLinkContext =  dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
+            xShape = pLinkContext->GetShape();
 
         return xShape;
     }
commit 192c05c532dbfe905ab520683abb4f04e85b5745
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:13:25 2015 +0100

    coverity#1325249 Unchecked dynamic_cast
    
    Change-Id: I5789d62424fd01705b64a111dbd121b15d89a3d9

diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 7984878..208129c 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -3606,7 +3606,7 @@ SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPref
                                                 IsXMLToken( rLocalName, XML_THUMBNAIL ) ) ) )
     {
         SvXMLImportContext *pImplContext = &mxImplContext;
-        pContext = dynamic_cast<SdXMLShapeContext*>( pImplContext  )->CreateChildContext( nPrefix,
+        pContext = dynamic_cast<SdXMLShapeContext&>(*pImplContext).CreateChildContext( nPrefix,
                                                                         rLocalName, xAttrList );
     }
     else if ( (XML_NAMESPACE_DRAW == nPrefix) && IsXMLToken( rLocalName, XML_IMAGE_MAP ) )
commit e31cd8f3ae7c1edc97369291266c75e8a3a4db8e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:12:06 2015 +0100

    coverity#1325250 Unchecked dynamic_cast
    
    Change-Id: Id52cad11d2ca4ef42a31c0905ee123ccd53e0677

diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 299ea38d..216210f 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -135,15 +135,14 @@ SbxVariable* getDefaultProp( SbxVariable* pRef )
     SbxVariable* pDefaultProp = NULL;
     if ( pRef->GetType() == SbxOBJECT )
     {
-          SbxObject* pObj = dynamic_cast<SbxObject*>( pRef );
-        if ( !pObj )
+        SbxObject* pObj = dynamic_cast<SbxObject*>(pRef);
+        if (!pObj)
         {
             SbxBase* pObjVarObj = pRef->GetObject();
             pObj = dynamic_cast<SbxObject*>( pObjVarObj );
         }
-        if ( pObj && 0 != dynamic_cast<const SbUnoObject*>( pObj) )
+        if (SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>(pObj))
         {
-            SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>( pObj );
             pDefaultProp = pUnoObj->GetDfltProperty();
         }
     }
commit 792d507eecbc4cb0117c83098aac2e18c4c4e36e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:09:43 2015 +0100

    coverity#1325251 Unchecked dynamic_cast
    
    Change-Id: I20495f27bc95f0f0e834cafbeae51e4e86c84b5b

diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index 89e0cc2..49d564b 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -1474,7 +1474,7 @@ void SfxAcceleratorConfigPage::Reset( const SfxItemSet* rSet )
     const SfxPoolItem* pMacroItem=0;
     if( SfxItemState::SET == rSet->GetItemState( SID_MACROINFO, true, &pMacroItem ) )
     {
-        m_pMacroInfoItem = dynamic_cast<const SfxMacroInfoItem*>( pMacroItem  );
+        m_pMacroInfoItem = &dynamic_cast<const SfxMacroInfoItem&>(*pMacroItem);
         m_pGroupLBox->SelectMacro( m_pMacroInfoItem );
     }
     else
commit 42f39d25c75c289e15079f7b8815f5244e06550b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:08:01 2015 +0100

    coverity#1325252 Unchecked dynamic_cast
    
    Change-Id: I70b4c9f705d3da294e3b93f2834db5add9198ec9

diff --git a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
index 63f0984..522f0a3 100644
--- a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
+++ b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
@@ -138,7 +138,7 @@ TextContentAnchorType XMLTextFrameHyperlinkContext::GetAnchorType() const
     if( xFrameContext.Is() )
     {
         SvXMLImportContext *pContext = &xFrameContext;
-        return dynamic_cast<XMLTextFrameContext*>( pContext ) ->GetAnchorType( );
+        return dynamic_cast<XMLTextFrameContext&>(*pContext).GetAnchorType();
     }
     else
         return eDefaultAnchorType;
commit d0ddb0c4a6aa4f65f45c6cbfbc2fa409720af53a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:07:27 2015 +0100

    coverity#1325253 Unchecked dynamic_cast
    
    Change-Id: I7151f641ce87fa7ca11af4f0cef6594edb925f91

diff --git a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
index a5cf777..63f0984 100644
--- a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
+++ b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
@@ -151,7 +151,7 @@ Reference < XTextContent > XMLTextFrameHyperlinkContext::GetTextContent() const
     if( xFrameContext.Is() )
     {
         SvXMLImportContext *pContext = &xFrameContext;
-        xTxt = dynamic_cast<XMLTextFrameContext*>( pContext )->GetTextContent( );
+        xTxt = dynamic_cast<XMLTextFrameContext&>(*pContext).GetTextContent();
     }
 
     return xTxt;
commit 9ecd848dc9467aef4f3d3d0f9b5c2e7086ae77d5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 1 14:06:38 2015 +0100

    coverity#1325254 Unchecked dynamic_cast
    
    Change-Id: I75f9f4cb4f32ae1836e1e6287fa5fce1aa83bdf5

diff --git a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
index fa34690..a5cf777 100644
--- a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
+++ b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
@@ -164,7 +164,7 @@ Reference < drawing::XShape > XMLTextFrameHyperlinkContext::GetShape() const
     if( xFrameContext.Is() )
     {
         SvXMLImportContext *pContext = &xFrameContext;
-        xShape = dynamic_cast<XMLTextFrameContext*>( pContext )->GetShape( );
+        xShape = dynamic_cast<XMLTextFrameContext&>(*pContext).GetShape();
     }
 
     return xShape;


More information about the Libreoffice-commits mailing list