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

Takeshi Abe tabe at fixedpoint.jp
Fri Jun 3 11:01:47 UTC 2016


 starmath/source/cursor.cxx |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 013f9d5aaa5799a7fe3ddfc2ff61ec449c0462b0
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Fri Jun 3 04:35:02 2016 +0900

    Null pointer dereferences must not happen
    
    This is a follow-up of 09981cd6383ecb99e4b6c83b98b03af5cf3ff59b.
    Inspired by coverity#1362478 etc.
    
    Change-Id: If5507c52552393cccbb255cbf4b7e9f4b80db917
    Reviewed-on: https://gerrit.libreoffice.org/25840
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 3baf5e1..dab3dc4 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -139,11 +139,14 @@ void SmCursor::BuildGraph(){
     }
     //Set position and anchor to first caret position
     auto it = mpGraph->begin();
+    assert(it != mpGraph->end());
     if(!mpPosition)
-        mpPosition = (it == mpGraph->end()) ? nullptr : it->get();
+        mpPosition = it->get();
     if(!mpAnchor)
         mpAnchor = mpPosition;
 
+    assert(mpPosition);
+    assert(mpAnchor);
     OSL_ENSURE(mpPosition->CaretPos.IsValid(), "Position must be valid");
     OSL_ENSURE(mpAnchor->CaretPos.IsValid(), "Anchor must be valid");
 }


More information about the Libreoffice-commits mailing list