Files
node/lib
Jinho Bang 9edf023694 n-api: throw RangeError napi_create_typedarray()
According to the ECMA spec, we should throw a RangeError in the
following cases:
  - `(length * elementSize) + offset` > the size of the array passed in
  - `offset % elementSize` != `0`

In the current implementation, this check was omitted. So, the following
code will cause a crash.
  ```
  napi_create_typedarray(env, napi_uint16_array, 2 /* length */,
                         buffer, 1 /* byte_offset */, &output_array);
  ```

This change fixes the problem and write some related tests.

Refs:
https://tc39.github.io/ecma262/#sec-typedarray-buffer-byteoffset-length

PR-URL: https://github.com/nodejs/node/pull/18037
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-01-30 10:19:34 -06:00
..
2018-01-08 02:21:03 -05:00
2017-08-28 00:39:42 +04:00
2018-01-10 01:42:28 -05:00
2016-10-04 12:17:32 -04:00
2017-03-10 11:23:48 -08:00
2018-01-15 06:42:17 -06:00
2017-12-12 03:28:03 -05:00
2017-12-11 15:52:34 -05:00
2018-01-09 04:32:46 -05:00
2018-01-08 02:20:03 -05:00