Bug 1270235 - Part 1: Check parent node is null in RemoveEmptyNodes. r=masayuki, a=gchang
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 13 Feb 2017 15:46:09 +0900
changeset 378567 9f46a26cc63fb71cff48d8c45a9f6ceb75e85888
parent 378566 2af32640ce76b13b41f2108652856907cc7dc623
child 378568 4a02468e067257db5c8f6cefc330bb3c30d1d541
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, gchang
bugs1270235
milestone53.0a2
Bug 1270235 - Part 1: Check parent node is null in RemoveEmptyNodes. r=masayuki, a=gchang RemoveEmptyNodes doesn't check whether parent node is null. So we shouldn't add null to skip list. Also, although this crash depends on clang, if debug build, it will hit the assertion on all compiler. MozReview-Commit-ID: GgiczVExlIn
editor/libeditor/HTMLEditRules.cpp
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -7680,17 +7680,19 @@ HTMLEditRules::RemoveEmptyNodes()
     OwningNonNull<nsINode> node = *iter->GetCurrentNode();
 
     nsCOMPtr<nsINode> parent = node->GetParentNode();
 
     size_t idx = skipList.IndexOf(node);
     if (idx != skipList.NoIndex) {
       // This node is on our skip list.  Skip processing for this node, and
       // replace its value in the skip list with the value of its parent
-      skipList[idx] = parent;
+      if (parent) {
+        skipList[idx] = parent;
+      }
     } else {
       bool bIsCandidate = false;
       bool bIsEmptyNode = false;
       bool bIsMailCite = false;
 
       if (node->IsElement()) {
         if (node->IsHTMLElement(nsGkAtoms::body)) {
           // Don't delete the body
@@ -7727,17 +7729,17 @@ HTMLEditRules::RemoveEmptyNodes()
             // mailcites go on a separate list from other empty nodes
             arrayOfEmptyCites.AppendElement(*node);
           } else {
             arrayOfEmptyNodes.AppendElement(*node);
           }
         }
       }
 
-      if (!bIsEmptyNode) {
+      if (!bIsEmptyNode && parent) {
         // put parent on skip list
         skipList.AppendElement(*parent);
       }
     }
 
     iter->Next();
   }