diff options
author | 2023-01-31 17:52:17 -0800 | |
---|---|---|
committer | 2023-01-31 17:52:17 -0800 | |
commit | c57b37d29f9d04780c7f7917789cf8b424710d23 (patch) | |
tree | bbe614e4ee842e4a9b5ce46a15944f04c607434d | |
parent | b09896f06ec81e606a7f7e344d2ac45a5e1ffd39 (diff) | |
download | bun-c57b37d29f9d04780c7f7917789cf8b424710d23.tar.gz bun-c57b37d29f9d04780c7f7917789cf8b424710d23.tar.zst bun-c57b37d29f9d04780c7f7917789cf8b424710d23.zip |
Handle invalid input in clear* timer
-rw-r--r-- | src/bun.js/api/bun.zig | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index d70de3aa9..0b47bea27 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -3139,12 +3139,16 @@ pub const Timer = struct { return JSValue.jsNumberWithType(i32, id); } - pub fn clearTimer(timer_id: JSValue, _: *JSGlobalObject, repeats: bool) void { + pub fn clearTimer(timer_id: JSValue, globalThis: *JSGlobalObject, repeats: bool) void { JSC.markBinding(@src()); var map = if (repeats) &VirtualMachine.get().timer.interval_map else &VirtualMachine.get().timer.timeout_map; + if (!timer_id.isAnyInt()) { + return; + } + const id: Timeout.ID = .{ - .id = timer_id.toInt32(), + .id = timer_id.coerce(i32, globalThis), .repeat = @as(u32, @boolToInt(repeats)), }; var timer = map.fetchSwapRemove(id.id) orelse return; |