buffer: fix single-character string filling
Checklist
-
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines
Affected core subsystem(s)
buffer
Description of change
Fix the fast path for buffer.fill()
with a single-character string.
The fast path only works for strings that are equivalent to a
single-byte buffer, but that condition was not checked properly
for the utf8
or utf16le
encodings and is always true for the
latin1
encoding.
This change fixes these problems.
Fixes: https://github.com/nodejs/node/issues/9836
/cc @nodejs/buffer
CI: https://ci.nodejs.org/job/node-test-commit/6222/
CI: https://ci.nodejs.org/job/node-test-commit/6224/
CI: https://ci.nodejs.org/job/node-test-commit/6600/