diff --git a/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp b/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp index 8e2c1ee5003..6cd056b2da6 100644 --- a/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp @@ -508,6 +508,13 @@ ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, "return(towrite)=%d, url=%s\n", this, npp, numtowrite, mNPStream.url)); + if (!mStreamStarted) { + // The plugin called NPN_DestroyStream() from within + // NPP_WriteReady(), kill the stream. + + return NS_BINDING_ABORTED; + } + // if WriteReady returned 0, the plugin is not ready to handle // the data, suspend the stream (if it isn't already // suspended). @@ -544,6 +551,13 @@ ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, this, npp, streamPosition, numtowrite, ptrStreamBuffer, writeCount, mNPStream.url)); + if (!mStreamStarted) { + // The plugin called NPN_DestroyStream() from within + // NPP_WriteReady(), kill the stream. + + return NS_BINDING_ABORTED; + } + if (writeCount > 0) { NS_ASSERTION(writeCount <= mStreamBufferByteCount, "Plugin read past the end of the available data!"); @@ -656,9 +670,9 @@ ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo, { StopDataPump(); - if (mIsSuspended && NS_FAILED(status)) { - // We're suspended, and the stream was destroyed, or died for some - // reason. Make sure we cancel the suspended request. + if (NS_FAILED(status)) { + // The stream was destroyed, or died for some reason. Make sure we + // cancel the underlying request. nsCOMPtr pluginInfo4x = do_QueryInterface(mStreamInfo); diff --git a/mozilla/modules/plugin/samples/default/windows/npshell.cpp b/mozilla/modules/plugin/samples/default/windows/npshell.cpp index cf2915b009c..1f57eef586f 100644 --- a/mozilla/modules/plugin/samples/default/windows/npshell.cpp +++ b/mozilla/modules/plugin/samples/default/windows/npshell.cpp @@ -252,6 +252,9 @@ NPP_WriteReady(NPP pInstance, NPStream *stream) CPlugin * pPlugin = (CPlugin *)pInstance->pdata; assert(pPlugin != NULL); + // We don't want any data, kill the stream + NPN_DestroyStream(pInstance, stream, NPRES_DONE); + return -1L; // dont accept any bytes in NPP_Write() } @@ -268,6 +271,9 @@ NPP_Write(NPP pInstance, NPStream *stream, int32 offset, int32 len, void *buffer CPlugin * pPlugin = (CPlugin *)pInstance->pdata; assert(pPlugin != NULL); + // We don't want any data, kill the stream + NPN_DestroyStream(pInstance, stream, NPRES_DONE); + return -1; // tell the browser to abort the stream, don't need it }