diff options
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/styled_buffer.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/styled_buffer.rs b/compiler/rustc_errors/src/styled_buffer.rs index b0f4ec84a89..790efd0286e 100644 --- a/compiler/rustc_errors/src/styled_buffer.rs +++ b/compiler/rustc_errors/src/styled_buffer.rs @@ -93,6 +93,9 @@ impl StyledBuffer { if start == end { return; } + if start > self.lines[line].len() || end > self.lines[line].len() { + return; + } let _ = self.lines[line].drain(start..(end - string.chars().count())); for (i, c) in string.chars().enumerate() { self.lines[line][start + i] = StyledChar::new(c, Style::LineNumber); |
