Skip to content

Commit f0af3b0

Browse files
ChALkeRevanlucas
authored andcommittedJun 12, 2018
doc: buffer.fill() can zero-fill on invalid input
Note that buffer.fill() can zero-fill on some input types if no valid fill data remains, but does nothing on other input types. PR-URL: https://github.com/nodejs-private/node-private/pull/120 Fixes: https://github.com/nodejs-private/security/issues/193 Refs: https://github.com/nodejs-private/node-private/pull/118 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 555696d commit f0af3b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎doc/api/buffer.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1177,8 +1177,12 @@ console.log(Buffer.allocUnsafe(3).fill('\u0222'));
11771177
// Prints: <Buffer c8 a2 c8>
11781178
```
11791179

1180-
If `value` contains invalid characters, it is truncated; if no valid
1181-
fill data remains, no filling is performed:
1180+
If `value` contains invalid characters, it is truncated.
1181+
1182+
If no valid fill data remains, then the buffer is either zero-filled or no
1183+
filling is performed, depending on the input type. That behavior is dictated by
1184+
compatibility reasons and was changed to throwing an exception in Node.js v10,
1185+
so it's not recommended to rely on that.
11821186

11831187
```js
11841188
const buf = Buffer.allocUnsafe(5);

0 commit comments

Comments
 (0)
Please sign in to comment.