diff options
author | Simon Ser <[email protected]> | 2021-12-21 12:05:05 +0100 |
---|---|---|
committer | Simon Ser <[email protected]> | 2021-12-23 12:16:37 +0100 |
commit | d7867d41c25e0a027a9900f3dde565c6caaa4890 (patch) | |
tree | e6289736db177a618568ef0d948a99570ce62d40 /sway/tree/container.c | |
parent | 5d16d15a95bfaa1d55255b108e4c86337b8900b5 (diff) |
Add cairo_image_surface_create error handling
cairo_image_surface_create can fail, e.g. when running out of
memory or when the size is too big. Avoid crashing in this case.
Closes: https://github.com/swaywm/sway/issues/6531
(cherry picked from commit 59aebaa5f9f3afe9cdfbb0d37c4dc631690da3b9)
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 132b6819..e5149fb6 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -536,6 +536,13 @@ static void render_titlebar_text_texture(struct sway_output *output, cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, width, height); + cairo_status_t status = cairo_surface_status(surface); + if (status != CAIRO_STATUS_SUCCESS) { + sway_log(SWAY_ERROR, "cairo_image_surface_create failed: %s", + cairo_status_to_string(status)); + return; + } + cairo_t *cairo = cairo_create(surface); cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); cairo_set_font_options(cairo, fo); |