Bug 1840626 - Fix debug Crash [@ mozilla::dom::ReadableStream::CloseNative] r=saschanaz

The assertion dereferences Algorithms(), which could have been freed, so only assert if it exists.

Differential Revision: https://phabricator.services.mozilla.com/D187149
This commit is contained in:
Andrew Creskey 2023-09-13 14:16:41 +00:00
Родитель 63ebdf7b61
Коммит aaedb8e230
2 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -1345,8 +1345,8 @@ already_AddRefed<ReadableStream> ReadableStream::CreateByteNative(
// https://streams.spec.whatwg.org/#readablestream-close
void ReadableStream::CloseNative(JSContext* aCx, ErrorResult& aRv) {
MOZ_ASSERT(mController->GetAlgorithms()->IsNative());
MOZ_ASSERT_IF(mController->GetAlgorithms(),
mController->GetAlgorithms()->IsNative());
// Step 1: If stream.[[controller]] implements ReadableByteStreamController,
if (mController->IsByte()) {
RefPtr<ReadableByteStreamController> controller = mController->AsByte();

Просмотреть файл

@ -65,3 +65,13 @@ add_task(async function test_webtransport_create() {
wt.close();
});
// bug 1840626 - cancel and then close
add_task(async function test_wt_stream_create_bidi_cancel_close() {
let wt = new WebTransport("https://" + host + "/success");
await wt.ready;
await wt.createBidirectionalStream();
await wt.incomingBidirectionalStreams.cancel(undefined);
wt.close();
});