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
--- 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();
}