Skip to content

buffer: fix crash for invalid index types

This is a forward-port of v10.x’s https://github.com/nodejs/node/pull/23795, which was originally targeting master, to fix https://github.com/nodejs/node/issues/23668.

As part of the discussion back then, we wanted to explore a “fix” for v11.x and master that involved introducing typechecking along the lines of https://github.com/nodejs/node/pull/23840, but since that hasn’t happened, it seems like a good idea to apply this on all affected branches, in order to make sure the bug is fixed everywhere.

This does not keep https://github.com/nodejs/node/pull/23840 from happening in any way (except that this makes it a semver-major PR).


2555cb4a introduced a crash when a non-number value was passed to ParseArrayIndex().

We do not always have JS typechecking for that in place, though. This returns back to the previous behavior of coercing values to integers, which is certainly questionable.

Refs: https://github.com/nodejs/node/pull/22129 Fixes: https://github.com/nodejs/node/issues/23668

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Merge request reports

Loading