diff options
author | 2023-04-25 21:59:19 -0700 | |
---|---|---|
committer | 2023-04-25 21:59:19 -0700 | |
commit | 88d47cceb41356cb066b9f9ad33e69d38efc43f8 (patch) | |
tree | 7d1f8937a0df2924005ecb3613dd1654964503b6 | |
parent | 6259dfdfd1a954f5e42314988fd58306cccc453c (diff) | |
download | bun-88d47cceb41356cb066b9f9ad33e69d38efc43f8.tar.gz bun-88d47cceb41356cb066b9f9ad33e69d38efc43f8.tar.zst bun-88d47cceb41356cb066b9f9ad33e69d38efc43f8.zip |
safer
-rw-r--r-- | src/bun.js/base.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index 1e5069de8..95757cf3b 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -4163,11 +4163,14 @@ pub const FinalizationCallback = struct { this.ref_count -= 1; } - pub fn ptr(this: *Ptr) ?*anyopaque { + pub fn ptr(this: Ptr) ?*anyopaque { if (this.address == 0) return null; - return @intToPtr(*anyopaque, @as(usize, this.addrress)); + // zero the trailing little endian 4 bits from u64 + // We want to make sure that the ref_count is not included in the pointer + const safe_addr = @as(usize, this.address) & @as(usize, 0xFFFFFFFFFFFFFFF0); + return @intToPtr(*anyopaque, safe_addr); } pub fn init(addr: *anyopaque) Ptr { |