Bug 1198435 - Call RemoveMediaElementFromURITable before modifying mLoadingSrc, so that a future LookupMediaElementURITable won't access this element anymore. r=rillian

--HG--
extra : rebase_source : 9702e206ed2bfaa0d32449e4f8798348ed307b63
This commit is contained in:
Gerald Squelart 2015-09-10 09:01:44 +02:00
parent 7c02d61a29
commit f31596e5a6
2 changed files with 13 additions and 9 deletions

View File

@ -724,6 +724,7 @@ void HTMLMediaElement::AbortExistingLoads()
EndSrcMediaStreamPlayback();
}
RemoveMediaElementFromURITable();
mLoadingSrc = nullptr;
mMediaSource = nullptr;
@ -932,6 +933,7 @@ void HTMLMediaElement::SelectResource()
NS_ASSERTION(!mIsLoadingFromSourceChildren,
"Should think we're not loading from source children by default");
RemoveMediaElementFromURITable();
mLoadingSrc = uri;
mMediaSource = mSrcMediaSource;
UpdatePreloadAction();
@ -1070,6 +1072,7 @@ void HTMLMediaElement::LoadFromSourceChildren()
continue;
}
RemoveMediaElementFromURITable();
mLoadingSrc = uri;
mMediaSource = childSrc->GetSrcMediaSource();
NS_ASSERTION(mNetworkState == nsIDOMHTMLMediaElement::NETWORK_LOADING,
@ -2002,15 +2005,13 @@ HTMLMediaElement::AddMediaElementToURITable()
void
HTMLMediaElement::RemoveMediaElementFromURITable()
{
NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 1,
"Before remove, should have a single entry for element in element table");
NS_ASSERTION(mDecoder, "Don't call this without decoder!");
NS_ASSERTION(mLoadingSrc, "Can't have decoder without source!");
if (!gElementTable)
if (!mDecoder || !mLoadingSrc || !gElementTable) {
return;
}
MediaElementSetForURI* entry = gElementTable->GetEntry(mLoadingSrc);
if (!entry)
if (!entry) {
return;
}
entry->mElements.RemoveElement(this);
if (entry->mElements.IsEmpty()) {
gElementTable->RemoveEntry(mLoadingSrc);
@ -2026,11 +2027,13 @@ HTMLMediaElement::RemoveMediaElementFromURITable()
HTMLMediaElement*
HTMLMediaElement::LookupMediaElementURITable(nsIURI* aURI)
{
if (!gElementTable)
if (!gElementTable) {
return nullptr;
}
MediaElementSetForURI* entry = gElementTable->GetEntry(aURI);
if (!entry)
if (!entry) {
return nullptr;
}
for (uint32_t i = 0; i < entry->mElements.Length(); ++i) {
HTMLMediaElement* elem = entry->mElements[i];
bool equal;
@ -3328,6 +3331,7 @@ void HTMLMediaElement::DecodeError()
if (mDecoder) {
ShutdownDecoder();
}
RemoveMediaElementFromURITable();
mLoadingSrc = nullptr;
mMediaSource = nullptr;
if (mIsLoadingFromSourceChildren) {

View File

@ -792,7 +792,7 @@ protected:
*/
void AddMediaElementToURITable();
/**
* Call this before clearing mLoadingSrc.
* Call this before modifying mLoadingSrc.
*/
void RemoveMediaElementFromURITable();
/**