diff options
author | 2022-08-28 21:19:53 +0800 | |
---|---|---|
committer | 2022-08-28 06:19:53 -0700 | |
commit | ce90e0c372f3e92b2a163d24018132aa2ce2ee6b (patch) | |
tree | c9c89bfed4f50838aa84361fe858afa79ca9259a /test/bun.js/ffi.test.fixture.callback.c | |
parent | 296fb41e920736041c6c1dec38f1d8c355a402a1 (diff) | |
download | bun-ce90e0c372f3e92b2a163d24018132aa2ce2ee6b.tar.gz bun-ce90e0c372f3e92b2a163d24018132aa2ce2ee6b.tar.zst bun-ce90e0c372f3e92b2a163d24018132aa2ce2ee6b.zip |
support pass null as NULL ptr (#1160)
Diffstat (limited to 'test/bun.js/ffi.test.fixture.callback.c')
-rw-r--r-- | test/bun.js/ffi.test.fixture.callback.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/bun.js/ffi.test.fixture.callback.c b/test/bun.js/ffi.test.fixture.callback.c index bd912dde2..f6e74f8ba 100644 --- a/test/bun.js/ffi.test.fixture.callback.c +++ b/test/bun.js/ffi.test.fixture.callback.c @@ -149,11 +149,17 @@ static bool JSVALUE_IS_NUMBER(EncodedJSValue val) { static void* JSVALUE_TO_PTR(EncodedJSValue val) { // must be a double + if (val.asInt64 == TagValueNull) + return 0; return (void*)(val.asInt64 - DoubleEncodeOffset); } static EncodedJSValue PTR_TO_JSVALUE(void* ptr) { EncodedJSValue val; + if (ptr == 0) { + val.asInt64 = TagValueNull; + return val; + } val.asInt64 = (int64_t)ptr + DoubleEncodeOffset; return val; } |