From ec55989494d35778cc64e84d18d6eca968e5c1b9 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 15 Oct 2014 00:40:06 +0900 Subject: [PATCH] Bug 1081992 Needs null check at notifying TextComposition of composition event being discarded r=smaug --- dom/events/IMEStateManager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dom/events/IMEStateManager.cpp b/dom/events/IMEStateManager.cpp index 7c47231e0252..663dd8baa2b5 100644 --- a/dom/events/IMEStateManager.cpp +++ b/dom/events/IMEStateManager.cpp @@ -979,6 +979,16 @@ IMEStateManager::OnCompositionEventDiscarded( nsRefPtr composition = sTextCompositions->GetCompositionFor(aCompositionEvent->widget); + if (!composition) { + // If the PresShell has been being destroyed during composition, + // a TextComposition instance for the composition was already removed from + // the array and destroyed in OnDestroyPresContext(). Therefore, we may + // fail to retrieve a TextComposition instance here. + PR_LOG(sISMLog, PR_LOG_ALWAYS, + ("ISM: IMEStateManager::OnCompositionEventDiscarded(), " + "TextComposition instance for the widget has already gone")); + return; + } composition->OnCompositionEventDiscarded(aCompositionEvent); }