Bug 1332876 - Bail out of HTMLEditRules::BeforeEdit if we have no Selection. r=masayuki a=jcristau
authorMats Palmgren <mats@mozilla.com>
Mon, 30 Jan 2017 04:54:37 +0100
changeset 378043 d6e53354c0346bede591b876c97561f03b50ef9d
parent 378042 10606a7696400f990722e323c1d9bfc35e6d612d
child 378044 0055af50eaefd44bf5f55745d17c0e86cc710d7d
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki, jcristau
bugs1332876
milestone53.0a2
Bug 1332876 - Bail out of HTMLEditRules::BeforeEdit if we have no Selection. r=masayuki a=jcristau
editor/libeditor/HTMLEditRules.cpp
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -317,17 +317,17 @@ HTMLEditRules::BeforeEdit(EditAction act
     mDidRangedDelete = false;
 
     // Remember where our selection was before edit action took place:
 
     // Get selection
     RefPtr<Selection> selection = htmlEditor->GetSelection();
 
     // Get the selection location
-    if (!selection->RangeCount()) {
+    if (NS_WARN_IF(!selection) || !selection->RangeCount()) {
       return NS_ERROR_UNEXPECTED;
     }
     mRangeItem->startNode = selection->GetRangeAt(0)->GetStartParent();
     mRangeItem->startOffset = selection->GetRangeAt(0)->StartOffset();
     mRangeItem->endNode = selection->GetRangeAt(0)->GetEndParent();
     mRangeItem->endOffset = selection->GetRangeAt(0)->EndOffset();
     nsCOMPtr<nsINode> selStartNode = mRangeItem->startNode;
     nsCOMPtr<nsINode> selEndNode = mRangeItem->endNode;