fix(node:buffer): fix Buffer.write stuck (#6651)

This commit is contained in:
Ai Hoshino
2023-10-23 04:42:05 +08:00
committed by GitHub
parent 4cdaabd433
commit 1836ecd2ed
2 changed files with 32 additions and 10 deletions

View File

@@ -2079,12 +2079,16 @@ pub fn copyLatin1IntoUTF8StopOnNonASCII(buf_: []u8, comptime Type: type, latin1_
}
}
if (latin1.len > 0 and buf.len >= 2) {
if (comptime stop) return .{ .written = std.math.maxInt(u32), .read = std.math.maxInt(u32) };
if (latin1.len > 0) {
if (buf.len >= 2) {
if (comptime stop) return .{ .written = std.math.maxInt(u32), .read = std.math.maxInt(u32) };
buf[0..2].* = latin1ToCodepointBytesAssumeNotASCII(latin1[0]);
latin1 = latin1[1..];
buf = buf[2..];
buf[0..2].* = latin1ToCodepointBytesAssumeNotASCII(latin1[0]);
latin1 = latin1[1..];
buf = buf[2..];
} else {
break;
}
}
}