-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
buffer: zero-fill buffer allocated with invalid content #17428
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
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1254,6 +1254,19 @@ Example: Fill a `Buffer` with a two-byte character | |
| console.log(Buffer.allocUnsafe(3).fill('\u0222')); | ||
| ``` | ||
|
|
||
| If `value` is contains invalid characters, it is truncated; if no valid | ||
| fill data remains, no filling is performed: | ||
|
|
||
| ```js | ||
| const buf = Buffer.allocUnsafe(5); | ||
| // Prints: <Buffer 61 61 61 61 61> | ||
| console.log(buf.fill('a')); | ||
| // Prints: <Buffer aa aa aa aa aa> | ||
| console.log(buf.fill('aazz', 'hex')); | ||
| // Prints: <Buffer aa aa aa aa aa> | ||
| console.log(buf.fill('zz', 'hex')); | ||
|
Member
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.
Edit: nvm.
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. It seems the comments cover the next line, not the previous.
Member
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. Yes, I misread, sorry. |
||
| ``` | ||
|
|
||
| ### buf.includes(value[, byteOffset][, encoding]) | ||
| <!-- YAML | ||
| added: v5.3.0 | ||
|
|
||
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.
Nit: extra 'is' before contains