Bug 1425091 - Part 1. Should check whether CreateNode is failure. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 15 Dec 2017 11:01:58 -0600
changeset 714515 470f37b1f012e2b11adc4fe41198f871699c063a
parent 714514 2e0db1b48499fcf1598f23e04211360f9d39b7af
child 714516 b91ab5dc396ee3038c0a541b56f9aa5ccc7097fd
push id93936
push userbmo:m_kato@ga2.so-net.ne.jp
push dateSat, 23 Dec 2017 22:43:42 +0000
reviewersmasayuki
bugs1425091
milestone59.0a1
Bug 1425091 - Part 1. Should check whether CreateNode is failure. r?masayuki This crash occurs when CreateNode returns nullptr that is error. So we should check whether this method is failure. MozReview-Commit-ID: 9jDOnEYSurG
editor/libeditor/HTMLEditRules.cpp
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -3729,16 +3729,19 @@ HTMLEditRules::WillMakeList(Selection* a
     if (!curList) {
       SplitNodeResult splitCurNodeResult =
         MaybeSplitAncestorsForInsert(listType, atCurNode);
       if (NS_WARN_IF(splitCurNodeResult.Failed())) {
         return splitCurNodeResult.Rv();
       }
       curList =
         htmlEditor->CreateNode(listType, splitCurNodeResult.SplitPoint());
+      if (NS_WARN_IF(!curList)) {
+        return NS_ERROR_FAILURE;
+      }
       // remember our new block for postprocessing
       mNewBlock = curList;
       // curList is now the correct thing to put curNode in
       prevListItem = nullptr;
 
       // atCurNode is now referring the right node with mOffset but
       // referring the left node with mRef.  So, invalidate it now.
       atCurNode.Clear();