Bug 1257363 - add null check so it doesn't crash. r=masayuki
authorJorg K
Sat, 02 Apr 2016 14:40:00 +0200
changeset 291513 823040191adc78b25f1c8ec6d0523c209b97598f
parent 291512 fd3ca174abe074fbde07dd3fb7efe1d5f5da477a
child 291514 e9de61f3bbccef4fe43639f3eb5f13a781f9b683
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1257363
milestone48.0a1
Bug 1257363 - add null check so it doesn't crash. r=masayuki
editor/libeditor/nsHTMLEditRules.cpp
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -5020,26 +5020,26 @@ nsHTMLEditRules::CheckForEmptyBlock(nsIN
       if (aAction == nsIEditor::eNext) {
         // Adjust selection to be right after it.
         res = aSelection->Collapse(blockParent, offset + 1);
         NS_ENSURE_SUCCESS(res, res);
 
         // Move to the start of the next node if it's a text.
         nsCOMPtr<nsIContent> nextNode = mHTMLEditor->GetNextNode(blockParent,
                                                                  offset + 1, true);
-        if (mHTMLEditor->IsTextNode(nextNode)) {
+        if (nextNode && mHTMLEditor->IsTextNode(nextNode)) {
           res = aSelection->Collapse(nextNode, 0);
           NS_ENSURE_SUCCESS(res, res);
         }
       } else {
         // Move to the end of the previous node if it's a text.
         nsCOMPtr<nsIContent> priorNode = mHTMLEditor->GetPriorNode(blockParent,
                                                                    offset,
                                                                    true);
-        if (mHTMLEditor->IsTextNode(priorNode)) {
+        if (priorNode && mHTMLEditor->IsTextNode(priorNode)) {
           res = aSelection->Collapse(priorNode, priorNode->TextLength());
           NS_ENSURE_SUCCESS(res, res);
         } else {
           res = aSelection->Collapse(blockParent, offset + 1);
           NS_ENSURE_SUCCESS(res, res);
         }
       }
     }