Skip to content

Commit 316edff

Browse files
committed
[vi] fix bugs and warnings
1 parent de6505f commit 316edff

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

editors/vi/editor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ pub struct Editor {
129129
/// Accumulated text for ex insert mode.
130130
ex_insert_text: Vec<String>,
131131
/// Whether running in headless mode (for testing).
132+
#[allow(dead_code)]
132133
headless: bool,
133134
}
134135

editors/vi/ui/terminal.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,16 @@ impl Terminal {
125125
return Ok(TerminalSize::default());
126126
}
127127

128-
// Validate and clamp values to safe bounds to protect against
129-
// malformed terminal responses that could cause division by zero
130-
// or excessive memory allocation
131-
let rows = ws.ws_row.clamp(Self::MIN_ROWS, Self::MAX_ROWS);
132-
let cols = ws.ws_col.clamp(Self::MIN_COLS, Self::MAX_COLS);
133-
134-
// If values were zero or invalid, use defaults
128+
// If values are zero or invalid, use defaults
135129
if ws.ws_row == 0 || ws.ws_col == 0 {
136130
return Ok(TerminalSize::default());
137131
}
138132

133+
// Clamp values to safe bounds to protect against
134+
// excessive memory allocation from malformed terminal responses
135+
let rows = ws.ws_row.clamp(Self::MIN_ROWS, Self::MAX_ROWS);
136+
let cols = ws.ws_col.clamp(Self::MIN_COLS, Self::MAX_COLS);
137+
139138
Ok(TerminalSize { rows, cols })
140139
}
141140
}

0 commit comments

Comments
 (0)