Bug 1270235 - Part 1. Check parent node is null in RemoveEmptyNodes. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 13 Feb 2017 15:46:09 +0900
changeset 482668 701eb200ef7e6e7d60dc37d28e37c7eec4a79c82
parent 482536 3d13ed042963d38eea0440ecd44a4f5177a71414
child 482669 acc7617957e760574b94038ff06d9215f1063188
push id45120
push userm_kato@ga2.so-net.ne.jp
push dateMon, 13 Feb 2017 06:51:56 +0000
reviewersmasayuki
bugs1270235
milestone54.0a1
Bug 1270235 - Part 1. Check parent node is null in RemoveEmptyNodes. r?masayuki 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
@@ -7694,17 +7694,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
@@ -7741,17 +7743,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();
   }