[Libreoffice-commits] core.git: starmath/source

Takeshi Abe tabe at fixedpoint.jp
Mon Feb 8 20:45:06 UTC 2016


 starmath/source/view.cxx     |    3 ++-
 starmath/source/visitors.cxx |   13 +++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

New commits:
commit 35fe6dfd2e9ff62a2a8634fc2cfe9e574661b545
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Fri Feb 5 17:55:34 2016 +0900

    starmath: Replace SAL_WARN_IF with assert
    
    These assertions must hold, otherwise the following code would
    dereference null pointer.
    
    Change-Id: I2b3887aad7116a7ea5176630a015975b8fc087f9
    Reviewed-on: https://gerrit.libreoffice.org/22140
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 5dcf07d..f247fa8 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -75,6 +75,7 @@
 #include "cursor.hxx"
 #include "accessibility.hxx"
 #include "ElementsDockingWindow.hxx"
+#include <cassert>
 #include <memory>
 
 #define MINZOOM sal_uInt16(25)
@@ -1769,7 +1770,7 @@ void SmViewShell::Execute(SfxRequest& rReq)
                     if(pFact)
                     {
                         xDlg.reset(pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aSet));
-                        SAL_WARN_IF( !xDlg, "starmath", "Dialog creation failed!" );
+                        assert(xDlg);
                         xDlg->SetLimits( MINZOOM, MAXZOOM );
                         if (xDlg->Execute() != RET_CANCEL)
                             pSet = xDlg->GetOutputItemSet();
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 7a44488..71c0752 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -12,6 +12,7 @@
 #include "visitors.hxx"
 #include "tmpdevice.hxx"
 #include "cursor.hxx"
+#include <cassert>
 
 // SmDefaultingVisitor
 
@@ -848,8 +849,8 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmSubSupNode* pNode )
                          *bodyLeft,
                          *bodyRight;
 
+    assert(mpRightMost);
     left = mpRightMost;
-    SAL_WARN_IF( !mpRightMost, "starmath", "mpRightMost shouldn't be NULL here!" );
 
     //Create bodyLeft
     SAL_WARN_IF( !pNode->GetBody(), "starmath", "SmSubSupNode Doesn't have a body!" );
@@ -1140,9 +1141,9 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmBinVerNode* pNode )
                          *numLeft,
                          *denomLeft;
 
+    assert(mpRightMost);
     //Set left
     left = mpRightMost;
-    SAL_WARN_IF( !mpRightMost, "starmath", "There must be a position in front of this" );
 
     //Create right
     right = mpGraph->Add( SmCaretPos( pNode, 1 ) );
@@ -1381,7 +1382,7 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmRootNode* pNode )
 {
     SmNode  *pExtra = pNode->GetSubNode( 0 ), //Argument, NULL for sqrt, and SmTextNode if cubicroot
             *pBody  = pNode->GetSubNode( 2 ); //Body of the root
-    SAL_WARN_IF( !pBody, "starmath", "pBody cannot be NULL" );
+    assert(pBody);
 
     SmCaretPosGraphEntry  *left,
                         *right,
@@ -1389,7 +1390,7 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmRootNode* pNode )
                         *bodyRight;
 
     //Get left and save it
-    SAL_WARN_IF( !mpRightMost, "starmath", "There must be a position in front of this" );
+    assert(mpRightMost);
     left = mpRightMost;
 
     //Create body left
@@ -1421,7 +1422,7 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmDynIntegralNode* pNode )
 {
     //! To be changed: Integrals don't have args.
     SmNode  *pBody  = pNode->Body(); //Body of the root
-    SAL_WARN_IF( !pBody, "starmath", "pBody cannot be NULL" );
+    assert(pBody);
 
     SmCaretPosGraphEntry  *left,
                         *right,
@@ -1429,7 +1430,7 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmDynIntegralNode* pNode )
                         *bodyRight;
 
     //Get left and save it
-    SAL_WARN_IF( !mpRightMost, "starmath", "There must be a position in front of this" );
+    assert(mpRightMost);
     left = mpRightMost;
 
     //Create body left


More information about the Libreoffice-commits mailing list