Bug 1478850 - FetchStreamReader must call HoldJSObject()/DropJSObjects, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 20 Nov 2018 18:24:26 +0100
changeset 447294 6ce084069f3883f3c4d6e7d912f591891b2399e7
parent 447293 e25e40a58667cc86d17fa52aa3704e42c598243e
child 447295 31a42178a876106cc4cce885b94afef0275d89c7
push id110017
push useramarchesini@mozilla.com
push dateTue, 20 Nov 2018 17:24:42 +0000
treeherdermozilla-inbound@6ce084069f38 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1478850
milestone65.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 1478850 - FetchStreamReader must call HoldJSObject()/DropJSObjects, r=smaug
dom/fetch/FetchStreamReader.cpp
--- a/dom/fetch/FetchStreamReader.cpp
+++ b/dom/fetch/FetchStreamReader.cpp
@@ -94,21 +94,25 @@ FetchStreamReader::Create(JSContext* aCx
 FetchStreamReader::FetchStreamReader(nsIGlobalObject* aGlobal)
   : mGlobal(aGlobal)
   , mOwningEventTarget(mGlobal->EventTargetFor(TaskCategory::Other))
   , mBufferRemaining(0)
   , mBufferOffset(0)
   , mStreamClosed(false)
 {
   MOZ_ASSERT(aGlobal);
+
+  mozilla::HoldJSObjects(this);
 }
 
 FetchStreamReader::~FetchStreamReader()
 {
   CloseAndRelease(nullptr, NS_BASE_STREAM_CLOSED);
+
+  mozilla::DropJSObjects(this);
 }
 
 // If a context is provided, an attempt will be made to cancel the reader.  The
 // only situation where we don't expect to have a context is when closure is
 // being triggered from the destructor or the WorkerRef is notifying.  If
 // we're at the destructor, it's far too late to cancel anything.  And if the
 // WorkerRef is being notified, the global is going away, so there's also
 // no need to do further JS work.