Bug 1403841 - IsSelectionEditable should check whether focus node and anchor node aren't null. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 29 Sep 2017 13:12:35 +0900
changeset 672438 826e41f430fad810565d30640dbb9b3e075bb70c
parent 672296 e6c32278f32cd5f7d159627b2157396b62d0c4a9
child 733792 fac2940fc8a1bbe1f1848c14e81b1201b45f10e9
push id82236
push userbmo:m_kato@ga2.so-net.ne.jp
push dateFri, 29 Sep 2017 04:16:32 +0000
reviewersmasayuki
bugs1403841, 1319340
milestone58.0a1
Bug 1403841 - IsSelectionEditable should check whether focus node and anchor node aren't null. r?masayuki This might be regression by bug 1319340, but there is crash signature from old version. We should check whether focus node and anchor node aren't null. MozReview-Commit-ID: J7npxN5kC9G
editor/libeditor/EditorBase.cpp
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -554,22 +554,28 @@ EditorBase::IsSelectionEditable()
 
   if (!mIsHTMLEditorClass) {
     // XXX we just check that the anchor node is editable at the moment
     //     we should check that all nodes in the selection are editable
     nsCOMPtr<nsINode> anchorNode = selection->GetAnchorNode();
     return anchorNode && IsEditable(anchorNode);
   }
 
+  nsINode* anchorNode = selection->GetAnchorNode();
+  nsINode* focusNode = selection->GetFocusNode();
+  if (!anchorNode || !focusNode) {
+    return false;
+  }
+
   // Per the editing spec as of June 2012: we have to have a selection whose
   // start and end nodes are editable, and which share an ancestor editing
   // host.  (Bug 766387.)
   bool isSelectionEditable = selection->RangeCount() &&
-                             selection->GetAnchorNode()->IsEditable() &&
-                             selection->GetFocusNode()->IsEditable();
+                             anchorNode->IsEditable() &&
+                             focusNode->IsEditable();
   if (!isSelectionEditable) {
     return false;
   }
 
   nsINode* commonAncestor =
     selection->GetAnchorFocusRange()->GetCommonAncestor();
   while (commonAncestor && !commonAncestor->IsEditable()) {
     commonAncestor = commonAncestor->GetParentNode();