aboutsummaryrefslogtreecommitdiff
path: root/src/renderer
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2018-03-13 07:07:40 +0100
committerJoe Wilm <jwilm@users.noreply.github.com>2018-03-12 23:07:40 -0700
commitb9ad0cfad30c6fd1328658d8195f552f24df6ff9 (patch)
tree396b4817804c008be4056096159627f5c525e489 /src/renderer
parent1977215b0be083f26d7670ed9c7c837f156274ea (diff)
downloadalacritty-b9ad0cfad30c6fd1328658d8195f552f24df6ff9.tar.gz
alacritty-b9ad0cfad30c6fd1328658d8195f552f24df6ff9.zip
Prevent negative cell dimensions (#1181)
Prevent the cell dimensions from going below 1, this bug resulted in allocation of large amounts of memory in the scrollback PR but is also present on master. Currently the approach is to just `panic!`, however an `eprintln!` and `exit` could be an alternative too. I don't think it's realistic to check this at startup and it should have no performance impact since the failing method is only called once at startup. To make it a bit more clear what kind of values are accepted, the datatypes of offsets and paddings have also been changed so that these don't accept floats anymore and padding can never be negative. This should allow us to be a bit more strict with the config to make sure that errors are printed when invalid values are specified (like negative padding). This fixes #1167.
Diffstat (limited to 'src/renderer')
-rw-r--r--src/renderer/mod.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs
index 5b53e70f..56ae4b14 100644
--- a/src/renderer/mod.rs
+++ b/src/renderer/mod.rs
@@ -123,8 +123,8 @@ pub struct ShaderProgram {
/// Rendering is split into two passes; 1 for backgrounds, and one for text
u_background: GLint,
- padding_x: f32,
- padding_y: f32,
+ padding_x: u8,
+ padding_y: u8,
}
@@ -165,7 +165,7 @@ pub struct GlyphCache {
font_size: font::Size,
/// glyph offset
- glyph_offset: Delta,
+ glyph_offset: Delta<i8>,
metrics: ::font::Metrics,
}
@@ -1017,8 +1017,8 @@ impl ShaderProgram {
u_cell_dim: cell_dim,
u_visual_bell: visual_bell,
u_background: background,
- padding_x: config.padding().x.floor(),
- padding_y: config.padding().y.floor(),
+ padding_x: config.padding().x,
+ padding_y: config.padding().y,
};
shader.update_projection(*size.width as f32, *size.height as f32);
@@ -1041,8 +1041,8 @@ impl ShaderProgram {
// NB Not sure why padding change only requires changing the vertical
// translation in the projection, but this makes everything work
// correctly.
- let ortho = cgmath::ortho(0., width - 2. * self.padding_x, 2. * self.padding_y, height,
- -1., 1.);
+ let ortho = cgmath::ortho(0., width - 2. * self.padding_x as f32, 2. * self.padding_y as f32,
+ height, -1., 1.);
let projection: [[f32; 4]; 4] = ortho.into();
info!("width: {}, height: {}", width, height);