mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
set length before copy (#10498)
This commit is contained in:
@@ -2672,8 +2672,9 @@ pub fn escapeHTMLForLatin1Input(allocator: std.mem.Allocator, latin1: []const u8
|
||||
|
||||
buf = try std.ArrayList(u8).initCapacity(allocator, latin1.len + @as(usize, Scalar.lengths[c]));
|
||||
const copy_len = @intFromPtr(ptr) - @intFromPtr(latin1.ptr);
|
||||
@memcpy(buf.items[0..copy_len], latin1[0..copy_len]);
|
||||
if (comptime Environment.allow_assert) assert(copy_len <= buf.capacity);
|
||||
buf.items.len = copy_len;
|
||||
@memcpy(buf.items[0..copy_len], latin1[0..copy_len]);
|
||||
any_needs_escape = true;
|
||||
break :scan_and_allocate_lazily;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user