bounds checking

This commit is contained in:
Jarred Sumner
2021-09-27 00:40:44 -07:00
parent eb3473125c
commit adf22db8b6

View File

@@ -5906,7 +5906,7 @@ pub const Macro = struct {
var nextArg = writer.eatArg() orelse return false;
if (js.JSValueIsArray(writer.ctx, nextArg.asRef())) {
const extras = nextArg.getLengthOfArray(JavaScript.VirtualMachine.vm.global);
count += @truncate(u16, extras) - 1;
count += std.math.max(@truncate(u16, extras), 1) - 1;
items.ensureUnusedCapacity(extras) catch unreachable;
items.expandToCapacity();
var new_writer = writer.*;