Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: improve ArrayBuffer brand check in ensureBuffer #429

Merged
merged 1 commit into from
Apr 9, 2021

Conversation

addaleax
Copy link
Contributor

@addaleax addaleax commented Apr 8, 2021

Description

instanceof is notoriously unreliable in JS, because it can
be fooled by prototype manipulation and breaks down entirely
for cross-realm brand checks.

Using Object.prototype.toString is generally a better choice
for this.

This also adds SharedArrayBuffer as an alternative, as both
should be treated the same under most circumstances.

`instanceof` is notoriously unreliable in JS, because it can
be fooled by prototype manipulation and breaks down entirely
for cross-realm brand checks.

Using `Object.prototype.toString` is generally a better choice
for this.

This also adds `SharedArrayBuffer` as an alternative, as both
should be treated the same under most circumstances.
@addaleax addaleax force-pushed the better-buffer-typecheck branch from e476412 to e53e6a7 Compare April 8, 2021 15:38
@nbbeeken nbbeeken requested review from a team, dariakp, nbbeeken, durran and emadum and removed request for a team and dariakp April 8, 2021 17:16
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

LGTM!
(NODE-3195)

@nbbeeken nbbeeken merged commit 99722f6 into mongodb:master Apr 9, 2021
@addaleax addaleax deleted the better-buffer-typecheck branch April 9, 2021 18:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants