Bug 1425091 - Part 4. EditorBase::MoveNode should check valid node that has parent node. r?masayuki
AutoMoveNodeSelNotify doesn't allow container is null. So we should reject
that parent of moving node is null.
MozReview-Commit-ID: DGNCicLJxuK
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -1891,17 +1891,20 @@ EditorBase::MoveNode(nsIContent* aNode,
{
MOZ_ASSERT(aNode);
MOZ_ASSERT(aParent);
MOZ_ASSERT(aOffset == -1 ||
(0 <= aOffset &&
AssertedCast<uint32_t>(aOffset) <= aParent->Length()));
nsCOMPtr<nsINode> oldParent = aNode->GetParentNode();
- int32_t oldOffset = oldParent ? oldParent->IndexOf(aNode) : -1;
+ if (NS_WARN_IF(!oldParent)) {
+ return NS_ERROR_FAILURE;
+ }
+ int32_t oldOffset = oldParent->IndexOf(aNode);
if (aOffset == -1) {
// Magic value meaning "move to end of aParent"
aOffset = AssertedCast<int32_t>(aParent->Length());
}
// Don't do anything if it's already in right place
if (aParent == oldParent && aOffset == oldOffset) {