fix(editor): prevent overflow in count modifier (#10930)

This commit is contained in:
RoloEdits 2024-06-12 18:24:24 -07:00 committed by GitHub
parent 62655e97f1
commit 9c479e6d2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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) => {