diff options
author | 2023-06-28 21:57:31 -0700 | |
---|---|---|
committer | 2023-06-28 21:57:31 -0700 | |
commit | 8984c819613b52b3cfaf1cd22fc059d0150eedfc (patch) | |
tree | 938c607470095f60a07489003ce0c8db5c7c8768 /src | |
parent | c6f6db95ffbbf13a68939f7c3de544b1285e8929 (diff) | |
download | bun-8984c819613b52b3cfaf1cd22fc059d0150eedfc.tar.gz bun-8984c819613b52b3cfaf1cd22fc059d0150eedfc.tar.zst bun-8984c819613b52b3cfaf1cd22fc059d0150eedfc.zip |
Prevent integer overflow
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/bindings/bindings.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 2b800ab8b..1c09378a8 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -4608,7 +4608,7 @@ pub const JSValue = enum(JSValueReprInt) { return 0; } - return @intFromFloat(u64, @max(len, 0)); + return @intFromFloat(u64, @max(@min(len, std.math.maxInt(i52)), 0)); } /// This function supports: @@ -4629,7 +4629,7 @@ pub const JSValue = enum(JSValueReprInt) { return null; } - return @intFromFloat(u64, @max(len, 0)); + return @intFromFloat(u64, @max(@min(len, std.math.maxInt(i52)), 0)); } /// Do not use this directly! |