diff options
author | 2023-01-29 19:01:47 -0800 | |
---|---|---|
committer | 2023-01-29 19:01:47 -0800 | |
commit | 49d8316922cb2ca65a7d4d8e2a2339eda110e3ad (patch) | |
tree | a5a994d4a007c8754350be3d1170174bdedd34dd | |
parent | 7a496fa41af35500423df9aeef9465fe017954c2 (diff) | |
download | bun-49d8316922cb2ca65a7d4d8e2a2339eda110e3ad.tar.gz bun-49d8316922cb2ca65a7d4d8e2a2339eda110e3ad.tar.zst bun-49d8316922cb2ca65a7d4d8e2a2339eda110e3ad.zip |
Make this more careful
-rw-r--r-- | src/string_immutable.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 0a4eb900e..a437baa69 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -1723,7 +1723,7 @@ pub fn copyLatin1IntoUTF16(comptime Buffer: type, buf_: Buffer, comptime Type: t var buf = buf_; var latin1 = latin1_; while (buf.len > 0 and latin1.len > 0) { - const to_write = strings.firstNonASCII(latin1) orelse @truncate(u32, latin1.len); + const to_write = strings.firstNonASCII(latin1) orelse @truncate(u32, @min(latin1.len, buf.len)); if (comptime std.meta.alignment(Buffer) != @alignOf(u16)) { strings.copyU8IntoU16WithAlignment(std.meta.alignment(Buffer), buf, latin1[0..to_write]); } else { |