[Libreoffice-commits] .: basic/source sd/source svx/source sw/source

Ivan Timofeev ivantimofeev at kemper.freedesktop.org
Fri Nov 4 12:11:34 PDT 2011


 basic/source/comp/exprtree.cxx |    8 +++++++-
 sd/source/ui/view/sdview2.cxx  |    2 +-
 svx/source/svdraw/svdpage.cxx  |   10 +++++-----
 sw/source/ui/dbui/dbmgr.cxx    |    4 +++-
 4 files changed, 16 insertions(+), 8 deletions(-)

New commits:
commit 9b94d385f94562049bf93f2fc0dd0558d6a56dd1
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Fri Nov 4 23:01:17 2011 +0400

    cppcheck: avoid possible null pointer dereferences

diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index 1c7ec1b..41caa05 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -983,8 +983,14 @@ SbiExpression* SbiExprList::Get( short n )
 
 void SbiExprList::addExpression( SbiExpression* pExpr )
 {
+    if( !pFirst )
+    {
+        pFirst = pExpr;
+        return;
+    }
+
     SbiExpression* p = pFirst;
-    while( p && p->pNext )
+    while( p->pNext )
         p = p->pNext;
 
     p->pNext = pExpr;
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index 68e9a1f..b1a87b1 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -466,10 +466,10 @@ void View::DragFinished( sal_Int8 nDropAction )
             nm--;
             SdrMark* pM=mpDragSrcMarkList->GetMark(nm);
             SdrObject* pObj=pM->GetMarkedSdrObj();
-            sal_uInt32 nOrdNum=pObj->GetOrdNumDirect();
 
             if( pObj && pObj->GetPage() )
             {
+                sal_uInt32 nOrdNum=pObj->GetOrdNumDirect();
 #ifdef DBG_UTIL
                 SdrObject* pChkObj =
 #endif
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 77f739b..63fe525 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -152,10 +152,10 @@ void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
         SdrObject* pSO=rSrcList.GetObj(no);
 
         SdrObject* pDO = pSO->Clone();
-        pDO->SetModel(pModel);
-        pDO->SetPage(pPage);
 
         if (pDO!=NULL) {
+            pDO->SetModel(pModel);
+            pDO->SetPage(pPage);
             NbcInsertObject(pDO,CONTAINER_APPEND,&aReason);
         } else {
             nCloneErrCnt++;
@@ -425,11 +425,11 @@ SdrObject* SdrObjList::NbcRemoveObject(sal_uIntPtr nObjNum)
     SdrObject* pObj=maList[nObjNum];
     RemoveObjectFromContainer(nObjNum);
 
-    // flushViewObjectContacts() clears the VOC's and those invalidate
-    pObj->GetViewContact().flushViewObjectContacts(true);
-
     DBG_ASSERT(pObj!=NULL,"Object zum Removen nicht gefunden");
     if (pObj!=NULL) {
+        // flushViewObjectContacts() clears the VOC's and those invalidate
+        pObj->GetViewContact().flushViewObjectContacts(true);
+
         DBG_ASSERT(pObj->IsInserted(),"ZObjekt hat keinen Inserted-Status");
         pObj->SetInserted(sal_False); // Ruft u.a. den UserCall
         pObj->SetObjList(NULL);
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index a732303..cd0baba 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -1779,6 +1779,8 @@ sal_Bool SwNewDBMgr::GetColumnCnt(const String& rSourceName, const String& rTabl
         aData.nCommandType = -1;
         pFound = FindDSData(aData, sal_False);
     }
+    if (!pFound)
+        return sal_False;
     //check validity of supplied record Id
     if(pFound->aSelection.getLength())
     {
@@ -1795,7 +1797,7 @@ sal_Bool SwNewDBMgr::GetColumnCnt(const String& rSourceName, const String& rTabl
         if(!bFound)
             return sal_False;
     }
-    if(pFound && pFound->xResultSet.is() && !pFound->bAfterSelection)
+    if(pFound->xResultSet.is() && !pFound->bAfterSelection)
     {
         sal_Int32 nOldRow = 0;
         try


More information about the Libreoffice-commits mailing list