Bug 1611895 - Make `EditorEventListener::DragOverOrDrop()` check whether the result of `DragEvent::GetRangeParentContentAndOffset()` returned `nullptr` or not r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 29 Jan 2020 10:36:32 +0000
changeset 512064 019ae805259f58a086c5358850f3b2c95b04518a
parent 512063 1e1237501a7db10081c583f55e41243566fb1c12
child 512065 2d73dd4ab49823034eb048da514a457b9c663795
push id37068
push usernerli@mozilla.com
push dateWed, 29 Jan 2020 15:51:04 +0000
treeherdermozilla-central@019ae805259f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1611895, 1610264
milestone74.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1611895 - Make `EditorEventListener::DragOverOrDrop()` check whether the result of `DragEvent::GetRangeParentContentAndOffset()` returned `nullptr` or not r=smaug `DragEvent::GetRangeParentContentAndOffset()` may return `nullptr`. Previously, it was checked and returned `NS_ERROR_FAILURE` before landing bug 1610264. This patch adds the null check which was accidentally removed. Differential Revision: https://phabricator.services.mozilla.com/D61208
editor/libeditor/EditorEventListener.cpp
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -743,16 +743,19 @@ nsresult EditorEventListener::DragOverOr
 
   if (DetachedFromEditorOrDefaultPrevented(aDragEvent->WidgetEventPtr())) {
     return NS_OK;
   }
 
   int32_t dropOffset = -1;
   nsCOMPtr<nsIContent> dropParentContent =
       aDragEvent->GetRangeParentContentAndOffset(&dropOffset);
+  if (NS_WARN_IF(!dropParentContent)) {
+    return NS_ERROR_FAILURE;
+  }
   if (DetachedFromEditor()) {
     RefuseToDropAndHideCaret(aDragEvent);
     return NS_OK;
   }
 
   bool notEditable = !dropParentContent->IsEditable() ||
                      mEditorBase->IsReadonly() || mEditorBase->IsDisabled();