summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/ansi.rs
diff options
context:
space:
mode:
authorKirill Chibisov <wchibisovkirill@gmail.com>2019-09-26 15:44:59 +0300
committerChristian Duerr <contact@christianduerr.com>2019-09-26 14:44:59 +0200
commitad24485cdb5a2b6559185c3c41adbf6852e5ac80 (patch)
tree549c7f44d03b3bf6668406ab1d73f5660d73dd69 /alacritty_terminal/src/ansi.rs
parentc1f089970fd3d4b9137d07647f8cd028b2b5b3a9 (diff)
downloadalacritty-ad24485cdb5a2b6559185c3c41adbf6852e5ac80.tar.gz
alacritty-ad24485cdb5a2b6559185c3c41adbf6852e5ac80.zip
Fix overflow on wrong scroll region setting
Fixes #2822.
Diffstat (limited to 'alacritty_terminal/src/ansi.rs')
-rw-r--r--alacritty_terminal/src/ansi.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs
index f95dc356..69391617 100644
--- a/alacritty_terminal/src/ansi.rs
+++ b/alacritty_terminal/src/ansi.rs
@@ -14,7 +14,6 @@
//
//! ANSI Terminal Stream Parsing
use std::io;
-use std::ops::Range;
use std::str;
use crate::index::{Column, Contains, Line};
@@ -296,7 +295,7 @@ pub trait Handler {
fn unset_mode(&mut self, _: Mode) {}
/// DECSTBM - Set the terminal scrolling region
- fn set_scrolling_region(&mut self, _: Range<Line>) {}
+ fn set_scrolling_region(&mut self, _top: usize, _bottom: usize) {}
/// DECKPAM - Set keypad to applications mode (ESCape instead of digits)
fn set_keypad_application_mode(&mut self) {}
@@ -1079,16 +1078,10 @@ where
handler.set_cursor_style(style);
},
('r', None) => {
- let arg0 = arg_or_default!(idx: 0, default: 1) as usize;
- let top = Line(arg0 - 1);
- // Bottom should be included in the range, but range end is not
- // usually included. One option would be to use an inclusive
- // range, but instead we just let the open range end be 1
- // higher.
- let arg1 = arg_or_default!(idx: 1, default: handler.lines().0 as _) as usize;
- let bottom = Line(arg1);
-
- handler.set_scrolling_region(top..bottom);
+ let top = arg_or_default!(idx: 0, default: 1) as usize;
+ let bottom = arg_or_default!(idx: 1, default: handler.lines().0 as _) as usize;
+
+ handler.set_scrolling_region(top, bottom);
},
('s', None) => handler.save_cursor_position(),
('u', None) => handler.restore_cursor_position(),