mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1722083 - revoke the listener first. r=bryce
Differential Revision: https://phabricator.services.mozilla.com/D121760
This commit is contained in:
parent
730a126d25
commit
e632260315
@ -619,6 +619,15 @@ already_AddRefed<BaseMediaResource> ChannelMediaResource::CloneData(
|
||||
void ChannelMediaResource::CloseChannel() {
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
|
||||
// Revoking listener should be done before canceling the channel, because
|
||||
// canceling the channel might cause the input stream to release its buffer.
|
||||
// If we don't do revoke first, it's possible that `OnDataAvailable` would be
|
||||
// called later and then incorrectly access that released buffer.
|
||||
if (mListener) {
|
||||
mListener->Revoke();
|
||||
mListener = nullptr;
|
||||
}
|
||||
|
||||
if (mChannel) {
|
||||
mSuspendAgent.Revoke();
|
||||
// The status we use here won't be passed to the decoder, since
|
||||
@ -631,11 +640,6 @@ void ChannelMediaResource::CloseChannel() {
|
||||
mChannel->Cancel(NS_ERROR_PARSED_DATA_CACHED);
|
||||
mChannel = nullptr;
|
||||
}
|
||||
|
||||
if (mListener) {
|
||||
mListener->Revoke();
|
||||
mListener = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult ChannelMediaResource::ReadFromCache(char* aBuffer, int64_t aOffset,
|
||||
|
Loading…
Reference in New Issue
Block a user