Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 22e1e54

Browse files
committed
fix: Don't attempt out of bounds buffer replacments
1 parent 2ef8888 commit 22e1e54

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

‎src/renderer/styled_buffer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ impl StyledBuffer {
103103
if start == end {
104104
return;
105105
}
106+
// If the replacement range would be out of bounds, do nothing, as we
107+
// can't replace things that don't exist.
108+
if start > self.lines[line].len() || end > self.lines[line].len() {
109+
return;
110+
}
106111
let _ = self.lines[line].drain(start..(end - string.chars().count()));
107112
for (i, c) in string.chars().enumerate() {
108113
self.lines[line][start + i] = StyledChar::new(c, ElementStyle::LineNumber);

‎tests/rustc_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2891,7 +2891,6 @@ $DIR/short-error-format.rs:8:7: error[E0599]: no method named `salut` found for
28912891
}
28922892

28932893
#[test]
2894-
#[should_panic(expected = "range end index 47 out of range for slice of length 26")]
28952894
fn rustdoc_ui_diagnostic_width() {
28962895
// tests/rustdoc-ui/diagnostic-width.rs
28972896

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /