From 35fe6dfd2e9ff62a2a8634fc2cfe9e574661b545 Mon Sep 17 00:00:00 2001 From: Takeshi Abe Date: Fri, 5 Feb 2016 17:55:34 +0900 Subject: 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 Tested-by: Michael Stahl --- starmath/source/view.cxx | 3 ++- starmath/source/visitors.cxx | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 5dcf07dfff4c..f247fa83ac14 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 #include #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 7a444881bac0..71c0752a6b64 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 // 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 -- cgit