chakra-core / chakra-core/ChakraCore

JsCreateTypedArray has wrong SAL annotation

Open
#5,872 4 comments 0 reactions 0 assignees View on GitHub
Bug Severity: 2
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

`JsCreateTypedArray` has the following signature in ChakraCore.h:
```c
CHAKRA_API
JsCreateTypedArray(
_In_ JsTypedArrayType arrayType,
_In_ JsValueRef baseArray,
_In_ unsigned int byteOffset,
_In_ unsigned int elementLength,
_Out_ JsValueRef *result);
```
However, according to the documentation comment just above that, baseArray can legally be `JS_INVALID_REFERENCE` (equivalent to NULL), in which case it creates the backing store on the fly:

```
The base array of the new array. Use JS_INVALID_REFERENCE if no base array.
```

Therefore the annotation for `baseArray` should be `_In_opt_`, not `_In_`. There are probably more like this, but this happened to be one I noticed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.