diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index 576d3f4a487..77ee34e91c9 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -2133,10 +2133,13 @@ nsObjectLoadingContent::StopPluginInstance() } #endif - DoStopPlugin(mInstanceOwner, delayedStop); - + // DoStopPlugin can process events and there may be pending InDocCheckEvent + // events which can drop in underneath us and destroy the instance we are + // about to destroy. Make sure this doesn't happen via this temp ref ptr and + // the !mInstanceOwner check above. + nsRefPtr instOwner = mInstanceOwner; mInstanceOwner = nsnull; - + DoStopPlugin(instOwner, delayedStop); return NS_OK; }