Files
node/lib
Jinho Bang ca10fda064 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

Backport-PR-URL: https://github.com/nodejs/node/pull/19265
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-05-01 17:16:28 -04:00
..
2017-12-20 01:58:39 +00:00
2017-09-12 03:18:13 +02:00
2018-02-26 23:51:04 -05:00
2018-04-13 11:46:49 +01:00
2016-10-04 12:17:32 -04:00
2017-03-10 11:23:48 -08:00
2017-12-13 15:50:43 +00:00
2018-03-29 23:28:16 -04:00
2018-04-10 16:30:50 +01:00