From 131045ce554f040224d25738b46524ab2fc23a3a Mon Sep 17 00:00:00 2001 From: llyyr Date: Sat, 21 Mar 2026 12:14:48 +0530 Subject: [PATCH] sway_text_node: properly check cairo_t status in text_calc_size cairo_create never returns NULL, so the previous null check never triggered. Use cairo_status instead. --- sway/sway_text_node.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sway/sway_text_node.c b/sway/sway_text_node.c index 46ddac93c..c4fd3a260 100644 --- a/sway/sway_text_node.c +++ b/sway/sway_text_node.c @@ -202,18 +202,20 @@ static void text_calc_size(struct text_buffer *buffer) { CAIRO_CONTENT_COLOR_ALPHA, NULL); cairo_t *c = cairo_create(recorder); cairo_surface_destroy(recorder); - if (!c) { - sway_log(SWAY_ERROR, "cairo_t allocation failed"); - return; + if (cairo_status(c) != CAIRO_STATUS_SUCCESS) { + sway_log(SWAY_ERROR, "cairo_t allocation failed: %s", + cairo_status_to_string(cairo_status(c))); + goto out; } cairo_set_antialias(c, CAIRO_ANTIALIAS_BEST); get_text_size(c, config->font_description, &props->width, NULL, &props->baseline, 1, props->pango_markup, "%s", buffer->text); - cairo_destroy(c); wlr_scene_buffer_set_dest_size(buffer->buffer_node, get_text_width(props), props->height); +out: + cairo_destroy(c); } struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent,