Ask questionsnapi_get_value_uint32 difference between Node 14 and previous
In sodium-native we have a special malloc that allows you to allocated a mmap'ed buffer with special flags that provide extra protection. The signature is
bytes can be up to
0xffffffff. Until Node 14
napi_get_value_uint32 would fail for numbers outside this range (eg.
Number.MAX_SAFE_INTEGER) but for Node 14 our tests now fail with varying errors on different operating system. My guess is that in Node 14, this wraps around, but it is unspecified by the napi docs whether wrap around does happen, so we might have relied on undefined behaviour.
Here is our failing tests: https://github.com/sodium-friends/sodium-native/blob/91e28b44648164ba8054f22e9a96c826329462bd/test/memory.js#L117-L125
Here is the macro we use to read a
uint32_t from a
Answer questions gabrielschulhof
@emilbayes I checked all the way back to v10.x and
napi_get_value_uint32() of -1 always returns 0xffffffff.