Skip to content

Commit

Permalink
Fix assertion failure in RespondInternal after transferring array buf…
Browse files Browse the repository at this point in the history
…fer in RespondWithNewView

Store view byte length before transferring.
  • Loading branch information
nidhijaju committed Oct 12, 2021
1 parent 1147c01 commit c079d53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.bs
Expand Up @@ -3489,9 +3489,10 @@ The following abstract operations support the implementation of the
|view|.\[[ViewedArrayBuffer]].\[[ByteLength]], throw a {{RangeError}} exception.
1. If |firstDescriptor|'s [=pull-into descriptor/bytes filled=] + |view|.\[[ByteLength]] >
|firstDescriptor|'s [=pull-into descriptor/byte length=], throw a {{RangeError}} exception.
1. Let |viewByteLength| be |view|.\[[ByteLength]].
1. Set |firstDescriptor|'s [=pull-into descriptor/buffer=] to ?
[$TransferArrayBuffer$](|view|.\[[ViewedArrayBuffer]]).
1. Perform ? [$ReadableByteStreamControllerRespondInternal$](|controller|, |view|.\[[ByteLength]]).
1. Perform ? [$ReadableByteStreamControllerRespondInternal$](|controller|, |viewByteLength|).
</div>

<div algorithm>
Expand Down
Expand Up @@ -1634,9 +1634,11 @@ function ReadableByteStreamControllerRespondWithNewView(controller, view) {
throw new RangeError('The region specified by view is larger than byobRequest');
}

const viewByteLength = view.byteLength;

firstDescriptor.buffer = TransferArrayBuffer(view.buffer);

ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
ReadableByteStreamControllerRespondInternal(controller, viewByteLength);
}

function ReadableByteStreamControllerShiftPendingPullInto(controller) {
Expand Down

0 comments on commit c079d53

Please sign in to comment.