Bug 1398045: Correctly handle channels that don't support weak references. r=mixedpuppy
authorKris Maglione <maglione.k@gmail.com>
Fri, 08 Sep 2017 08:56:42 -0700
changeset 379704 c5047f299f6072182266ef9a9be65cd5d7a9b51b
parent 379703 eaec8440ef8f7c11dfd10a38d15fe216ec2ab016
child 379705 ec521bf6357cf3564d5785a66da787be53be45cd
push id94729
push usermaglione.k@gmail.com
push dateFri, 08 Sep 2017 16:47:32 +0000
treeherdermozilla-inbound@c5047f299f60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1398045
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1398045: Correctly handle channels that don't support weak references. r=mixedpuppy MozReview-Commit-ID: GX6zUAzVrBZ
toolkit/components/extensions/webrequest/ChannelWrapper.h
--- a/toolkit/components/extensions/webrequest/ChannelWrapper.h
+++ b/toolkit/components/extensions/webrequest/ChannelWrapper.h
@@ -46,41 +46,41 @@ namespace detail {
   // members directly from our ChannelWrapper class.
   struct ChannelHolder
   {
     explicit ChannelHolder(nsIChannel* aChannel)
       : mChannel(do_GetWeakReference(aChannel))
       , mWeakChannel(aChannel)
     {}
 
-    bool HaveChannel() const { return mChannel->IsAlive(); }
+    bool HaveChannel() const { return mChannel && mChannel->IsAlive(); }
 
     void SetChannel(nsIChannel* aChannel)
     {
       mChannel = do_GetWeakReference(aChannel);
       mWeakChannel = aChannel;
       mWeakHttpChannel.reset();
     }
 
     already_AddRefed<nsIChannel> MaybeChannel() const
     {
-      if (!mChannel->IsAlive()) {
+      if (!HaveChannel()) {
         mWeakChannel = nullptr;
       }
       return do_AddRef(mWeakChannel);
     }
 
     already_AddRefed<nsIHttpChannel> MaybeHttpChannel() const
     {
       if (mWeakHttpChannel.isNothing()) {
         nsCOMPtr<nsIHttpChannel> chan = QueryChannel();
         mWeakHttpChannel.emplace(chan.get());
       }
 
-      if (!mChannel->IsAlive()) {
+      if (!HaveChannel()) {
         mWeakHttpChannel.ref() = nullptr;
       }
       return do_AddRef(mWeakHttpChannel.value());
     }
 
     const nsQueryReferent QueryChannel() const { return do_QueryReferent(mChannel); }
 
   private: