Bug 1113121 - Null check the parent node in nsHTMLEditRules::JoinNodesSmart() before passing it to MoveNode; r=roc a=sylvestre
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 12 Jan 2015 13:05:56 -0500
changeset 242897 64d25509541e
parent 242896 c15f51963788
child 242898 84bf56da4a55
push id4332
push usereakhgari@mozilla.com
push date2015-01-17 15:11 +0000
treeherdermozilla-beta@64d25509541e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, sylvestre
bugs1113121
milestone36.0
Bug 1113121 - Null check the parent node in nsHTMLEditRules::JoinNodesSmart() before passing it to MoveNode; r=roc a=sylvestre
editor/libeditor/nsHTMLEditRules.cpp
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -7392,17 +7392,18 @@ nsHTMLEditRules::SplitAsNeeded(nsIAtom& 
  *
  * Returns the point where they're merged, or (nullptr, -1) on failure.
  */
 ::DOMPoint
 nsHTMLEditRules::JoinNodesSmart(nsIContent& aNodeLeft, nsIContent& aNodeRight)
 {
   // Caller responsible for left and right node being the same type
   nsCOMPtr<nsINode> parent = aNodeLeft.GetParentNode();
-  int32_t parOffset = parent ? parent->IndexOf(&aNodeLeft) : -1;
+  NS_ENSURE_TRUE(parent, ::DOMPoint());
+  int32_t parOffset = parent->IndexOf(&aNodeLeft);
   nsCOMPtr<nsINode> rightParent = aNodeRight.GetParentNode();
 
   // If they don't have the same parent, first move the right node to after the
   // left one
   nsresult res;
   if (parent != rightParent) {
     NS_ENSURE_TRUE(mHTMLEditor, ::DOMPoint());
     res = mHTMLEditor->MoveNode(&aNodeRight, parent, parOffset);