Bug 1477469 - Check for null composition pointer; r?esawin draft
authorJim Chen <nchen@mozilla.com>
Tue, 24 Jul 2018 18:14:05 -0400
changeset 822195 df3aa3d577af9dc0e6f56555f2ff750d6cf2942e
parent 819215 547144f5596c1a146b208d68d93950a6313080ca
child 822196 84ff8d05f37ce307b1dd5e1a0335a4f777209690
push id117313
push userbmo:nchen@mozilla.com
push dateTue, 24 Jul 2018 22:14:55 +0000
reviewersesawin
bugs1477469
milestone63.0a1
Bug 1477469 - Check for null composition pointer; r?esawin Check for null TextComposition pointer, which can apparently happen during regular usage. MozReview-Commit-ID: 6nKjyBVL2vF
widget/android/GeckoEditableSupport.cpp
--- a/widget/android/GeckoEditableSupport.cpp
+++ b/widget/android/GeckoEditableSupport.cpp
@@ -986,17 +986,18 @@ GeckoEditableSupport::OnImeReplaceText(i
 
     RefPtr<TextComposition> composition(GetComposition());
     MOZ_ASSERT(!composition || !composition->IsEditorHandlingEvent());
 
     nsString string(aText->ToString());
     const bool composing = !mIMERanges->IsEmpty();
     nsEventStatus status = nsEventStatus_eIgnore;
 
-    if (!mIMEKeyEvents.IsEmpty() || !mDispatcher->IsComposing() ||
+    if (!mIMEKeyEvents.IsEmpty() ||
+        !composition || !mDispatcher->IsComposing() ||
         uint32_t(aStart) != composition->NativeOffsetOfStartComposition() ||
         uint32_t(aEnd) != composition->NativeOffsetOfStartComposition() +
                           composition->String().Length()) {
         // Only start a new composition if we have key events,
         // if we don't have an existing composition, or
         // the replaced text does not match our composition.
         RemoveComposition();
 
@@ -1147,17 +1148,17 @@ GeckoEditableSupport::OnImeUpdateComposi
      * text content.  Only the offsets are specified and not the text content
      * to eliminate the possibility of this event altering the text content
      * unintentionally.
      */
     nsString string;
     RefPtr<TextComposition> composition(GetComposition());
     MOZ_ASSERT(!composition || !composition->IsEditorHandlingEvent());
 
-    if (!mDispatcher->IsComposing() ||
+    if (!composition || !mDispatcher->IsComposing() ||
         uint32_t(aStart) != composition->NativeOffsetOfStartComposition() ||
         uint32_t(aEnd) != composition->NativeOffsetOfStartComposition() +
                           composition->String().Length()) {
         if (keepCurrent) {
             // Don't start a new composition if we want to keep the current one.
             mIMERanges->Clear();
             return;
         }