aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-12-22 19:31:38 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-12-22 19:31:38 +0000
commit41f7f8b7fad601422cf9b458928b73b210ba994a (patch)
tree5d5fe7c4fcbc748a0fa7858c979dba8c43f9dbea
parentconfig: csd.border_width now always reflects the full/total width (diff)
render: make sure ‘maximized’ button doesn’t use negative coordinates
-rw-r--r--CHANGELOG.md2
-rw-r--r--render.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9a972955..e2febfff 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -64,6 +64,8 @@
(https://codeberg.org/dnkl/foot/issues/844).
* Crash when setting a key- or mouse binding to the empty string
(https://codeberg.org/dnkl/foot/issues/851).
+* Crash when maximizing the window and `[csd].size=1`
+ (https://codeberg.org/dnkl/foot/issues/857).
### Security
diff --git a/render.c b/render.c
index ca411c14..b21b23ce 100644
--- a/render.c
+++ b/render.c
@@ -1887,11 +1887,15 @@ render_csd_button_maximize_maximized(
const int max_width = buf->width / 3;
int width = min(max_height, max_width);
- int thick = 1 * term->scale;
+ int thick = min(width / 2, 1 * term->scale);
const int x_margin = (buf->width - width) / 2;
const int y_margin = (buf->height - width) / 2;
+ xassert(x_margin + width - thick >= 0);
+ xassert(width - 2 * thick >= 0);
+ xassert(y_margin + width - thick >= 0);
+
pixman_image_fill_rectangles(
PIXMAN_OP_SRC, buf->pix[0], &color, 4,
(pixman_rectangle16_t[]){