Skip to content

buffer: coerce offset using Math.trunc()

Rodrigo Muino Tomonari requested to merge github/fork/cjihrig/buf into master
Checklist
  • make -j8 test (UNIX), or vcbuild 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

Merge request reports

Loading