buffer: coerce offset using Math.trunc()
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
This is a partial revert of 14d1a8a6, which coerced the offset
of Buffer#slice()
using the |
operator. This causes some edge cases to be handled incorrectly. This commit restores the old behavior, but converts offsets to integers using Math.trunc()
. This commit does not revert any tests, and adds an additional
regression test.
Refs: https://github.com/nodejs/node/pull/9101 Refs: https://github.com/nodejs/node/issues/9096
cc: @nodejs/buffer