This commit is contained in:
Jarred Sumner
2024-04-29 17:16:48 -07:00
committed by GitHub
parent cacf97ca0a
commit ce4f85c2c5
3 changed files with 48 additions and 0 deletions

View File

@@ -449,6 +449,16 @@ pub const LineColumnOffset = struct {
var iter = strings.CodepointIterator.initOffset(input, i);
var cursor = strings.CodepointIterator.Cursor{ .i = @as(u32, @truncate(iter.i)) };
_ = iter.next(&cursor);
// Given a null byte, cursor.width becomes 0
// This can lead to integer overflow, crashes, or hangs.
// https://github.com/oven-sh/bun/issues/10624
if (cursor.width == 0) {
columns += 1;
offset = i + 1;
continue;
}
offset = i + cursor.width;
switch (cursor.c) {