Browse Source

Prevent crashes from extremely long lines

Luna Stadler 4 years ago
parent
commit
d04e535aed
1 changed files with 4 additions and 1 deletions
  1. 4 1
      zig/sdl/hello_sdl.zig

+ 4 - 1
zig/sdl/hello_sdl.zig

@ -729,7 +729,10 @@ pub fn main() !void {
729 729
                }
730 730
            }
731 731
            while (line != null and i * glyph_height < window_height) {
732
                const skipped_line = line.?[std.math.min(skip_horizontal, line.?.len)..];
732
                var skipped_line = line.?[std.math.min(skip_horizontal, line.?.len)..];
733
                if (skipped_line.len > line_buf.len) {
734
                    skipped_line = skipped_line[0 .. line_buf.len - 1];
735
                }
733 736
734 737
                // fix tabs
735 738
                const repl_size = std.mem.replacementSize(u8, skipped_line, "\t", " " ** 8);