diff --git a/src/terminal/draw.c b/src/terminal/draw.c index 93382b4d..6deb72a0 100644 --- a/src/terminal/draw.c +++ b/src/terminal/draw.c @@ -503,6 +503,8 @@ draw_text(struct terminal *term, int x, int y, assert(text && length >= 0); if_assert_failed return; + if (x >= term->width || y >= term->height) return; + #ifdef CONFIG_UTF8 if (term->utf8_cp) { draw_text_utf8(term, x, y, text, length, attr, color); diff --git a/src/util/box.h b/src/util/box.h index 4e3a36b9..b155dd2b 100644 --- a/src/util/box.h +++ b/src/util/box.h @@ -46,10 +46,10 @@ colspan_is_in_box(struct box *box, int x, int span) static inline void set_box(struct box *box, int x, int y, int width, int height) { - box->x = x; - box->y = y; - box->width = width; - box->height = height; + box->x = int_max(0, x); + box->y = int_max(0, y); + box->width = int_max(0, width); + box->height = int_max(0, height); } /** @relates box */