Skip to content

Commit f25b31c

Browse files
committed
Fix diff overflow
1 parent c36d881 commit f25b31c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

DiffMatchPatch.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ fn diffLinesToChars(
654654
try line_array.append(allocator, "");
655655

656656
// Allocate 2/3rds of the space for text1, the rest for text2.
657-
var chars1 = try diffLinesToCharsMunge(allocator, text1, &line_array, &line_hash, 40000);
658-
var chars2 = try diffLinesToCharsMunge(allocator, text2, &line_array, &line_hash, 65535);
657+
var chars1 = try diffLinesToCharsMunge(allocator, text1, &line_array, &line_hash, 170);
658+
var chars2 = try diffLinesToCharsMunge(allocator, text2, &line_array, &line_hash, 255);
659659
return .{ .chars_1 = chars1, .chars_2 = chars2, .line_array = line_array };
660660
}
661661

@@ -691,7 +691,7 @@ fn diffLinesToCharsMunge(
691691
try chars.append(allocator, @intCast(u8, value));
692692
} else {
693693
if (line_array.items.len == max_lines) {
694-
// Bail out at 65535 because char 65536 == char 0.
694+
// Bail out at 255 because char 256 == char 0.
695695
line = text[@intCast(usize, line_start)..];
696696
line_end = @intCast(isize, text.len);
697697
}

0 commit comments

Comments
 (0)