Skip to content

Commit

Permalink
fix(editor): prevent overflow in count modifier (#10930)
Browse files Browse the repository at this point in the history
  • Loading branch information
RoloEdits committed Jun 13, 2024
1 parent 62655e9 commit 9c479e6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,11 @@ impl EditorView {
// If the count is already started and the input is a number, always continue the count.
(key!(i @ '0'..='9'), Some(count)) => {
let i = i.to_digit(10).unwrap() as usize;
cxt.editor.count = NonZeroUsize::new(count.get() * 10 + i);
let count = count.get() * 10 + i;
if count > 100_000_000 {
return;
}
cxt.editor.count = NonZeroUsize::new(count);
}
// A non-zero digit will start the count if that number isn't used by a keymap.
(key!(i @ '1'..='9'), None) if !self.keymaps.contains_key(mode, event) => {
Expand Down

0 comments on commit 9c479e6

Please sign in to comment.