filter/source/msfilter/msdffimp.cxx |   46 +++++++++++++-----------------------
 1 file changed, 17 insertions(+), 29 deletions(-)

New commits:
commit 22dfffe39ff1a61e73af9778e34ca40827d10da3
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Oct 21 12:36:08 2018 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Oct 21 14:05:51 2018 +0200

    tdf#120703 (PVS): redundant nullptr checks; use range-based for
    
    V668 There is no sense in testing the 'pRet' pointer against null, as the
         memory was allocated using the 'new' operator. The exception will be
         generated in the case of memory allocation error.
    
    V1029 Numeric Truncation Error. Result of the 'size' function is written to
         the 16-bit variable.
    
    V595 The 'pStData' pointer was utilized before it was verified against
         nullptr. Check lines: 6380, 6384.
    
    V1004 The 'pStData' pointer was used unsafely after it was verified against
         nullptr. Check lines: 6384, 6389.
    
    V668 There is no sense in testing the 'pData' pointer against null, as the
         memory was allocated using the 'new' operator. The exception will be
         generated in the case of memory allocation error.
    
    Change-Id: I9110c25dee3751ddd9a875ea52969ec097730780
    Reviewed-on: https://gerrit.libreoffice.org/62129
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/filter/source/msfilter/msdffimp.cxx 
b/filter/source/msfilter/msdffimp.cxx
index 70a30e3eaa84..59a60d772fbd 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3983,7 +3983,7 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, 
SfxItemSet& rSet, cons
         }
 
         // set the size from BLIP if there is one
-        if ( pRet && bGrfRead && !aVisArea.IsEmpty() )
+        if ( bGrfRead && !aVisArea.IsEmpty() )
             pRet->SetBLIPSizeRectangle( aVisArea );
 
         if (pRet->GetName().isEmpty())                   // SJ 22.02.00 : PPT 
OLE IMPORT:
@@ -5619,16 +5619,13 @@ void SvxMSDffManager::StoreShapeOrder(sal_uLong         
nId,
                                       SdrObject*    pObject,
                                       SwFlyFrameFormat*  pFly) const
 {
-    sal_uInt16 nShpCnt = m_aShapeOrders.size();
-    for (sal_uInt16 nShapeNum=0; nShapeNum < nShpCnt; nShapeNum++)
+    for (const auto& pOrder : m_aShapeOrders)
     {
-        SvxMSDffShapeOrder& rOrder = *m_aShapeOrders[ nShapeNum ];
-
-        if( rOrder.nShapeId == nId )
+        if (pOrder->nShapeId == nId)
         {
-            rOrder.nTxBxComp = nTxBx;
-            rOrder.pObj      = pObject;
-            rOrder.pFly      = pFly;
+            pOrder->nTxBxComp = nTxBx;
+            pOrder->pObj = pObject;
+            pOrder->pFly = pFly;
         }
     }
 }
@@ -5638,16 +5635,13 @@ void SvxMSDffManager::ExchangeInShapeOrder( SdrObject 
const * pOldObject,
                                             sal_uLong    nTxBx,
                                             SdrObject*   pObject) const
 {
-    sal_uInt16 nShpCnt = m_aShapeOrders.size();
-    for (sal_uInt16 nShapeNum=0; nShapeNum < nShpCnt; nShapeNum++)
+    for (const auto& pOrder : m_aShapeOrders)
     {
-        SvxMSDffShapeOrder& rOrder = *m_aShapeOrders[ nShapeNum ];
-
-        if( rOrder.pObj == pOldObject )
+        if (pOrder->pObj == pOldObject)
         {
-            rOrder.pFly      = nullptr;
-            rOrder.pObj      = pObject;
-            rOrder.nTxBxComp = nTxBx;
+            pOrder->pFly = nullptr;
+            pOrder->pObj = pObject;
+            pOrder->nTxBxComp = nTxBx;
         }
     }
 }
@@ -5655,16 +5649,13 @@ void SvxMSDffManager::ExchangeInShapeOrder( SdrObject 
const * pOldObject,
 
 void SvxMSDffManager::RemoveFromShapeOrder( SdrObject const * pObject ) const
 {
-    sal_uInt16 nShpCnt = m_aShapeOrders.size();
-    for (sal_uInt16 nShapeNum=0; nShapeNum < nShpCnt; nShapeNum++)
+    for (const auto& pOrder : m_aShapeOrders)
     {
-        SvxMSDffShapeOrder& rOrder = *m_aShapeOrders[ nShapeNum ];
-
-        if( rOrder.pObj == pObject )
+        if (pOrder->pObj == pObject)
         {
-            rOrder.pObj      = nullptr;
-            rOrder.pFly      = nullptr;
-            rOrder.nTxBxComp = 0;
+            pOrder->pObj = nullptr;
+            pOrder->pFly = nullptr;
+            pOrder->nTxBxComp = 0;
         }
     }
 }
@@ -6381,7 +6372,7 @@ bool SvxMSDffManager::GetBLIP( sal_uLong nIdx_, Graphic& 
rGraphic, tools::Rectan
 
         // remember FilePos of the stream(s)
         sal_uLong nOldPosCtrl = rStCtrl.Tell();
-        sal_uLong nOldPosData = pStData ? pStData->Tell() : nOldPosCtrl;
+        sal_uLong nOldPosData = pStData->Tell();
 
         // fetch matching info struct out of the pointer array
         SvxMSDffBLIPInfo& rInfo = (*m_pBLIPInfos)[ nIdx-1 ];
@@ -6866,9 +6857,6 @@ bool SvxMSDffManager::ConvertToOle2( SvStream& rStm, 
sal_uInt32 nReadLen,
             if( xOle10Stm.is() )
             {
                 std::unique_ptr<sal_uInt8[]> pData(new sal_uInt8[ nDataLen ]);
-                if( !pData )
-                    return false;
-
                 rStm.ReadBytes(pData.get(), nDataLen);
 
                 // write to ole10 stream
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to