From cfea88ed5f733367aab1b6d11066728633101898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Poisot?= Date: Fri, 20 Mar 2026 19:09:49 +0000 Subject: [PATCH] sway/sway_text_node: fix cairo_create() error checking As per the manual, this function cannot return NULL --- sway/sway_text_node.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sway/sway_text_node.c b/sway/sway_text_node.c index ded3e5295..87d93fdcb 100644 --- a/sway/sway_text_node.c +++ b/sway/sway_text_node.c @@ -107,8 +107,10 @@ static void render_backing_buffer(struct text_buffer *buffer) { } cairo_t *cairo = cairo_create(surface); - if (!cairo) { - sway_log(SWAY_ERROR, "cairo_create failed"); + status = cairo_status(cairo); + if (status != CAIRO_STATUS_SUCCESS) { + sway_log(SWAY_ERROR, "cairo_create() failed: %s", + cairo_status_to_string(status)); free(cairo_buffer); goto err; } @@ -200,8 +202,10 @@ static void text_calc_size(struct text_buffer *buffer) { cairo_surface_t *dummy_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); cairo_t *c = cairo_create(dummy_surface); - if (!c) { - sway_log(SWAY_ERROR, "cairo_t allocation failed"); + cairo_status_t status = cairo_status(c); + if (status != CAIRO_STATUS_SUCCESS) { + sway_log(SWAY_ERROR, "cairo_create() failed: %s", + cairo_status_to_string(status)); return; }