Bug 1324505 - Part 1. Check whether parent node is null. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 11 Jan 2017 19:03:41 +0900
changeset 459544 d873de724996400c2a72eec79194a3ffc36ffc2a
parent 459458 13603af3862d9583ed2feefb06e0988c2d7fed8c
child 459545 af2ab1d8998f4caa0f1a5a6a02e7f188f31b2d6c
push id41260
push userm_kato@ga2.so-net.ne.jp
push dateThu, 12 Jan 2017 06:01:18 +0000
reviewersmasayuki
bugs1324505
milestone53.0a1
Bug 1324505 - Part 1. Check whether parent node is null. r?masayuki designMode is too strange. Parent of common ancestor of selection might be nullptr, so we should check whether nullptr. MozReview-Commit-ID: Cy1k2Mpkws0
editor/libeditor/HTMLEditRules.cpp
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -7859,17 +7859,20 @@ HTMLEditRules::PopListItem(nsIDOMNode* a
   nsCOMPtr<Element> listItem = do_QueryInterface(aListItem);
   // check parms
   NS_ENSURE_TRUE(listItem && aOutOfList, NS_ERROR_NULL_POINTER);
 
   // init out params
   *aOutOfList = false;
 
   nsCOMPtr<nsINode> curParent = listItem->GetParentNode();
-  int32_t offset = curParent ? curParent->IndexOf(listItem) : -1;
+  if (NS_WARN_IF(!curParent)) {
+    return NS_ERROR_FAILURE;
+  }
+  int32_t offset = curParent->IndexOf(listItem);
 
   if (!HTMLEditUtils::IsListItem(listItem)) {
     return NS_ERROR_FAILURE;
   }
 
   // if it's first or last list item, don't need to split the list
   // otherwise we do.
   nsCOMPtr<nsINode> curParPar = curParent->GetParentNode();