From 14d3a98bf70151ecdb5bcd869e2351ebb1ff16a1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 18 Jan 2025 12:45:44 +0530 Subject: [PATCH] Fix crash with large text Need to find a better way to render the dotted decoration. Will do that later, just fix the crash for now. --- kitty/decorations.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kitty/decorations.c b/kitty/decorations.c index 0aa410c4c34..360a03bab3b 100644 --- a/kitty/decorations.c +++ b/kitty/decorations.c @@ -100,7 +100,7 @@ distribute_dots(unsigned available_space, unsigned num_of_dots, unsigned *summed DecorationGeometry add_dotted_underline(uint8_t *buf, FontCellMetrics fcm) { - unsigned num_of_dots = fcm.cell_width / (2 * fcm.underline_thickness); + unsigned num_of_dots = MAX(1u, fcm.cell_width / (2 * fcm.underline_thickness)); RAII_ALLOC(unsigned, spacing, malloc(num_of_dots * 2 * sizeof(unsigned))); if (!spacing) fatal("Out of memory"); unsigned size = distribute_dots(fcm.cell_width, num_of_dots, spacing, spacing + num_of_dots);