diff options
author | 2021-12-21 12:05:05 +0100 | |
---|---|---|
committer | 2021-12-21 14:52:08 -0700 | |
commit | 59aebaa5f9f3afe9cdfbb0d37c4dc631690da3b9 (patch) | |
tree | e94fcd1ac98f17f97b6aa30ed50c4605064bcc02 | |
parent | swaybar: fix errno handling in status_handle_readable (diff) | |
download | sway-59aebaa5f9f3afe9cdfbb0d37c4dc631690da3b9.tar.gz sway-59aebaa5f9f3afe9cdfbb0d37c4dc631690da3b9.tar.zst sway-59aebaa5f9f3afe9cdfbb0d37c4dc631690da3b9.zip |
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
-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, | |||
536 | 536 | ||
537 | cairo_surface_t *surface = cairo_image_surface_create( | 537 | cairo_surface_t *surface = cairo_image_surface_create( |
538 | CAIRO_FORMAT_ARGB32, width, height); | 538 | CAIRO_FORMAT_ARGB32, width, height); |
539 | cairo_status_t status = cairo_surface_status(surface); | ||
540 | if (status != CAIRO_STATUS_SUCCESS) { | ||
541 | sway_log(SWAY_ERROR, "cairo_image_surface_create failed: %s", | ||
542 | cairo_status_to_string(status)); | ||
543 | return; | ||
544 | } | ||
545 | |||
539 | cairo_t *cairo = cairo_create(surface); | 546 | cairo_t *cairo = cairo_create(surface); |
540 | cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); | 547 | cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); |
541 | cairo_set_font_options(cairo, fo); | 548 | cairo_set_font_options(cairo, fo); |