Bug 1188421 - Properly null memory reporter's compressor reference. r=hurley
authorNate Hughes <nhughes@mozilla.com>
Thu, 30 Jul 2015 12:31:43 -0700
changeset 287319 a8619079dbcb7bb943da042fa0f6078f079671c4
parent 287318 cf4c24bd630122e5d3a8ffb1f11f1f0a8bc25ebd
child 287320 82ce9a2fcd3d85c4afb124b49c0bd8e30e83d0aa
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershurley
bugs1188421
milestone42.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 1188421 - Properly null memory reporter's compressor reference. r=hurley
netwerk/protocol/http/Http2Compression.cpp
--- a/netwerk/protocol/http/Http2Compression.cpp
+++ b/netwerk/protocol/http/Http2Compression.cpp
@@ -58,28 +58,34 @@ public:
   explicit HpackDynamicTableReporter(Http2BaseCompressor* aCompressor)
     : mCompressor(aCompressor)
   {}
 
   NS_IMETHODIMP
   CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
                  bool aAnonymize) override
   {
+    if (!mCompressor) {
+      return NS_OK;
+    }
+
     return MOZ_COLLECT_REPORT(
       "explicit/network/hpack/dynamic-tables", KIND_HEAP, UNITS_BYTES,
       mCompressor->SizeOfExcludingThis(MallocSizeOf),
       "Aggregate memory usage of HPACK dynamic tables.");
   }
 
 private:
   MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
 
   ~HpackDynamicTableReporter() {}
 
   Http2BaseCompressor* mCompressor;
+
+  friend class Http2BaseCompressor;
 };
 
 NS_IMPL_ISUPPORTS(HpackDynamicTableReporter, nsIMemoryReporter)
 
 StaticRefPtr<HpackStaticTableReporter> gStaticReporter;
 
 void
 Http2CompressionCleanup()
@@ -277,16 +283,18 @@ Http2BaseCompressor::Http2BaseCompressor
 {
   mDynamicReporter = new HpackDynamicTableReporter(this);
   RegisterStrongMemoryReporter(mDynamicReporter);
 }
 
 Http2BaseCompressor::~Http2BaseCompressor()
 {
   UnregisterStrongMemoryReporter(mDynamicReporter);
+  mDynamicReporter->mCompressor = nullptr;
+  mDynamicReporter = nullptr;
 }
 
 void
 Http2BaseCompressor::ClearHeaderTable()
 {
   mHeaderTable.Clear();
 }