-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
stream: fix isDetachedBuffer validations in ReadableStream
#44114
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
Changes from 1 commit
e5e32c0
50c7728
6f6ba3e
782c71a
e44effa
6fd3ea1
0cc34f4
fe816cd
58da0d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -132,8 +132,7 @@ function transferArrayBuffer(buffer) { | |||
| } | ||||
|
|
||||
| function isDetachedBuffer(buffer) { | ||||
| if (!isArrayBuffer(buffer)) | ||||
| throw new ERR_INVALID_ARG_TYPE('buffer', 'ArrayBuffer', buffer); | ||||
| assert(isArrayBuffer(buffer)); | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this useful? I think the error thrown by V8 enough (and clearer).
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On second thought, seemingly it can be deleted in the current version of this PR. Fixed. |
||||
| if (ArrayBufferGetByteLength(buffer) === 0) { | ||||
|
LiviaMedeiros marked this conversation as resolved.
|
||||
| // TODO(daeyeon): Consider using C++ builtin to improve performance. | ||||
| try { | ||||
|
|
@@ -147,13 +146,7 @@ function isDetachedBuffer(buffer) { | |||
| } | ||||
|
|
||||
| function isViewedArrayBufferDetached(view) { | ||||
| if (!isArrayBufferView(view)) { | ||||
| throw new ERR_INVALID_ARG_TYPE( | ||||
| 'view', | ||||
| ['Buffer', 'TypedArray', 'DataView'], | ||||
| view, | ||||
| ); | ||||
| } | ||||
| assert(isArrayBufferView(view)); | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here
Suggested change
|
||||
| return ( | ||||
| ArrayBufferViewGetByteLength(view) === 0 && | ||||
| isDetachedBuffer(ArrayBufferViewGetBuffer(view)) | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use
validateBufferinstead?node/lib/internal/validators.js
Lines 200 to 206 in d83446b