From ba427a469a8394cb2fafa1a0602d6fd78c5c4d68 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Fri, 2 Feb 2024 00:35:53 +0100 Subject: [PATCH] Ensure get_text_width() returns a positive value Closes: https://github.com/swaywm/sway/issues/7940 --- sway/sway_text_node.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sway/sway_text_node.c b/sway/sway_text_node.c index b9a77d94d..664db40e9 100644 --- a/sway/sway_text_node.c +++ b/sway/sway_text_node.c @@ -58,11 +58,11 @@ struct text_buffer { }; static int get_text_width(struct sway_text_node *props) { + int width = props->width; if (props->max_width) { - return MIN(props->max_width, props->width); + width = MIN(width, props->max_width); } - - return props->width; + return MAX(width, 0); } static void update_source_box(struct text_buffer *buffer) {