Bug 711866 - Don't null deref when shutting down during media load algorithm. r=roc
authorChris Pearce <chris@pearce.org.nz>
Fri, 06 Jan 2012 19:40:51 +1300
changeset 86361 9e534250c98b00aea8c8000e4967bdd0626806e4
parent 86360 4779d8df054b671e7e44deaed81a83ae9bb6b0e0
child 86362 a8504f16777020cdf38dc15fe138178053707ece
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs711866
milestone12.0a1
Bug 711866 - Don't null deref when shutting down during media load algorithm. r=roc
content/html/content/src/nsHTMLMediaElement.cpp
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -297,16 +297,21 @@ void nsHTMLMediaElement::ReportLoadError
                                   aParamCount);
 }
 
 
 NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
 {
   nsContentUtils::UnregisterShutdownObserver(this);
 
+  if (!mElement) {
+    // We've been notified by the shutdown observer, and are shutting down.
+    return NS_BINDING_ABORTED;
+  }
+
   // The element is only needed until we've had a chance to call
   // InitializeDecoderForChannel. So make sure mElement is cleared here.
   nsRefPtr<nsHTMLMediaElement> element;
   element.swap(mElement);
 
   if (mLoadID != element->GetCurrentLoadID()) {
     // The channel has been cancelled before we had a chance to create
     // a decoder. Abort, don't dispatch an "error" event, as the new load