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

View File

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