Bug 584143 - Crashes when streams are open and a plugin instance is closed at/under nsNPAPIPluginInstance::Stop, r=bsmedberg
authorJosh Aas <joshmoz@gmail.com>
Mon, 09 Aug 2010 14:38:43 -0400
changeset 49224 6f169212eec6b756a3161b15e82dda7cbe0df304
parent 49223 dcff266c39b1edd3c8137529f2bdb0479d840bb9
child 49225 81344fe5f7a0eddd4d94c2c59fc97df54ea1d3e1
push id14952
push userbsmedberg@mozilla.com
push dateMon, 09 Aug 2010 18:39:03 +0000
treeherderautoland@33939a23c4b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs584143
milestone2.0b4pre
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 584143 - Crashes when streams are open and a plugin instance is closed at/under nsNPAPIPluginInstance::Stop, r=bsmedberg
modules/plugin/base/src/nsNPAPIPluginInstance.cpp
--- a/modules/plugin/base/src/nsNPAPIPluginInstance.cpp
+++ b/modules/plugin/base/src/nsNPAPIPluginInstance.cpp
@@ -177,20 +177,21 @@ NS_IMETHODIMP nsNPAPIPluginInstance::Sto
   EnterAsyncPluginThreadCallLock();
   mRunning = DESTROYING;
   mStopTime = TimeStamp::Now();
   ExitAsyncPluginThreadCallLock();
 
   OnPluginDestroy(&mNPP);
 
   // clean up open streams
-  for (unsigned int i = 0; i < mPStreamListeners.Length(); i++) {
-    mPStreamListeners[i]->CleanUpStream(NPRES_USER_BREAK);
+  while (mPStreamListeners.Length() > 0) {
+    nsRefPtr<nsNPAPIPluginStreamListener> currentListener(mPStreamListeners[0]);
+    currentListener->CleanUpStream(NPRES_USER_BREAK);
+    mPStreamListeners.RemoveElement(currentListener);
   }
-  mPStreamListeners.Clear();
 
   if (!mPlugin)
     return NS_ERROR_FAILURE;
 
   PluginLibrary* library = mPlugin->GetLibrary();
   if (!library)
     return NS_ERROR_FAILURE;