Bug 758872 - Fix missing null-check for plugin instance. r=bsmedberg
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Thu, 04 Apr 2013 00:00:45 +0200
changeset 127550 3ccf83ffd75a2d83d658386bec8fbfd725be6aee
parent 127549 5b710d7fe07360f3f866db10697e5d4c552e13fb
child 127551 55ec568f51a2a70503948036a17d53ab8d74cbb4
push id1655
push userbhackett@mozilla.com
push dateThu, 11 Apr 2013 23:17:41 +0000
reviewersbsmedberg
bugs758872
milestone23.0a1
Bug 758872 - Fix missing null-check for plugin instance. r=bsmedberg
dom/plugins/base/nsPluginInstanceOwner.cpp
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -1744,17 +1744,17 @@ void nsPluginInstanceOwner::ExitFullScre
   } 
 }
 
 #endif
 
 nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
 {
 #ifdef MOZ_WIDGET_ANDROID
-  {
+  if (mInstance) {
     ANPEvent event;
     event.inSize = sizeof(ANPEvent);
     event.eventType = kLifecycle_ANPEventType;
 
     nsAutoString eventType;
     aFocusEvent->GetType(eventType);
     if (eventType.EqualsLiteral("focus")) {
       event.data.lifecycle.action = kGainFocus_ANPLifecycleAction;
@@ -1901,16 +1901,18 @@ nsresult nsPluginInstanceOwner::Dispatch
     }
   }
   return NS_OK;
 }
 
 nsresult
 nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
 {
+  NS_ASSERTION(mInstance, "Should have a valid plugin instance or not receive events.");
+
   nsAutoString eventType;
   aEvent->GetType(eventType);
   if (eventType.EqualsLiteral("focus")) {
     mContentFocused = true;
     return DispatchFocusToPlugin(aEvent);
   }
   if (eventType.EqualsLiteral("blur")) {
     mContentFocused = false;