Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(op_crates/web) let TextEncoder#encodeInto accept detached ArrayBuffers #9143

Merged
merged 3 commits into from Jan 18, 2021
Merged

fix(op_crates/web) let TextEncoder#encodeInto accept detached ArrayBuffers #9143

merged 3 commits into from Jan 18, 2021

Conversation

ghost
Copy link

@ghost ghost commented Jan 17, 2021

Fixes what I had found, that I posted in a comment.

Currently, TextEncoder#encodeInto lets an exception propograte to the callee when called with a detached JS ArrayBuffer.

Detached array buffers have zero bytes, there is otherwise no way in JS (without V8 intrinsics) to determine whether or not an ArrayBuffer is detached.

As a side-effect, this optimizes the case when passing an empty ArrayBuffer that isn't detached into TextEncoder#encodeInto.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM- thanks

@ry ry merged commit db3a1d6 into denoland:master Jan 18, 2021
@ghost ghost deleted the patch-5 branch January 18, 2021 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant