summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZac Pullar-Strecker <zacps@users.noreply.github.com>2018-11-25 10:08:02 +1300
committerGitHub <noreply@github.com>2018-11-25 10:08:02 +1300
commit742a6b48a196cabf65354862548c07d057a28d55 (patch)
treefb9846aa3880eec27627b3ac91535d963390e947 /src
parent0d47cd25b90deecc2dbf40c8361d2310049fdde7 (diff)
downloadalacritty-742a6b48a196cabf65354862548c07d057a28d55.tar.gz
alacritty-742a6b48a196cabf65354862548c07d057a28d55.zip
Fix for an underflow on some type conversions (#1715)
Diffstat (limited to 'src')
-rw-r--r--src/term/mod.rs4
-rw-r--r--src/tty/windows.rs6
2 files changed, 6 insertions, 4 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 5107dc2d..193d7188 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -865,8 +865,8 @@ impl SizeInfo {
let line = Line(y.saturating_sub(self.padding_y as usize) / (self.cell_height as usize));
Point {
- line: min(line, self.lines() - 1),
- col: min(col, self.cols() - 1)
+ line: min(line, Line(self.lines().saturating_sub(1))),
+ col: min(col, Column(self.cols().saturating_sub(1)))
}
}
}
diff --git a/src/tty/windows.rs b/src/tty/windows.rs
index 9a452955..44715b39 100644
--- a/src/tty/windows.rs
+++ b/src/tty/windows.rs
@@ -19,6 +19,7 @@ use std::os::windows::io::{FromRawHandle, IntoRawHandle};
use std::os::windows::fs::OpenOptionsExt;
use std::env;
use std::cell::UnsafeCell;
+use std::u16;
use dunce::canonicalize;
use mio;
@@ -276,8 +277,9 @@ impl<'a> EventedReadWrite for Pty<'a, NamedPipe, NamedPipe> {
impl<'a> OnResize for Winpty<'a> {
fn on_resize(&mut self, sizeinfo: &SizeInfo) {
- if sizeinfo.cols().0 > 0 && sizeinfo.lines().0 > 0 {
- self.set_size(sizeinfo.cols().0, sizeinfo.lines().0)
+ let (cols, lines) = (sizeinfo.cols().0, sizeinfo.lines().0);
+ if cols > 0 && cols <= u16::MAX as usize && lines > 0 && lines <= u16::MAX as usize {
+ self.set_size(cols as u16, lines as u16)
.unwrap_or_else(|_| info!("Unable to set winpty size, did it die?"));
}
}