Bug 1155503: BrowserStreamParent should null out its NPStream pointer and we should check for it; r=jimm

This commit is contained in:
Aaron Klotz
2015-04-20 17:04:33 -06:00
parent b27c3f996d
commit a01b04f99f
2 changed files with 9 additions and 3 deletions

View File

@@ -35,6 +35,7 @@ BrowserStreamParent::BrowserStreamParent(PluginInstanceParent* npp,
BrowserStreamParent::~BrowserStreamParent() BrowserStreamParent::~BrowserStreamParent()
{ {
mStream->pdata = nullptr;
} }
void void
@@ -51,7 +52,6 @@ BrowserStreamParent::RecvAsyncNPP_NewStreamResult(const NPError& rv,
PluginAsyncSurrogate* surrogate = mNPP->GetAsyncSurrogate(); PluginAsyncSurrogate* surrogate = mNPP->GetAsyncSurrogate();
MOZ_ASSERT(surrogate); MOZ_ASSERT(surrogate);
surrogate->AsyncCallArriving(); surrogate->AsyncCallArriving();
nsRefPtr<nsNPAPIPluginStreamListener> streamListener = mStreamListener.forget();
if (mState == DEFERRING_DESTROY) { if (mState == DEFERRING_DESTROY) {
// We've been asked to destroy ourselves before init was complete. // We've been asked to destroy ourselves before init was complete.
mState = DYING; mState = DYING;
@@ -61,10 +61,10 @@ BrowserStreamParent::RecvAsyncNPP_NewStreamResult(const NPError& rv,
NPError error = rv; NPError error = rv;
if (error == NPERR_NO_ERROR) { if (error == NPERR_NO_ERROR) {
if (!streamListener) { if (!mStreamListener) {
return false; return false;
} }
if (streamListener->SetStreamType(stype)) { if (mStreamListener->SetStreamType(stype)) {
mState = ALIVE; mState = ALIVE;
} else { } else {
error = NPERR_GENERIC_ERROR; error = NPERR_GENERIC_ERROR;

View File

@@ -1419,6 +1419,12 @@ PluginInstanceParent::NPP_DestroyStream(NPStream* stream, NPReason reason)
FULLFUNCTION, (void*) stream, (int) reason)); FULLFUNCTION, (void*) stream, (int) reason));
AStream* s = static_cast<AStream*>(stream->pdata); AStream* s = static_cast<AStream*>(stream->pdata);
if (!s) {
// The stream has already been deleted by other means.
// With async plugin init this could happen if async NPP_NewStream
// returns an error code.
return NPERR_NO_ERROR;
}
if (s->IsBrowserStream()) { if (s->IsBrowserStream()) {
BrowserStreamParent* sp = BrowserStreamParent* sp =
static_cast<BrowserStreamParent*>(s); static_cast<BrowserStreamParent*>(s);