aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/api/FFI.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/api/FFI.h')
-rw-r--r--src/bun.js/api/FFI.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bun.js/api/FFI.h b/src/bun.js/api/FFI.h
index d7776dd23..bbe13bb5a 100644
--- a/src/bun.js/api/FFI.h
+++ b/src/bun.js/api/FFI.h
@@ -148,11 +148,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;
}