Skip to content

Commit

Permalink
Add cairo_image_surface_create error handling
Browse files Browse the repository at this point in the history
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: #6531
(cherry picked from commit 59aebaa)
  • Loading branch information
emersion committed Dec 23, 2021
1 parent 5d16d15 commit d7867d4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sway/tree/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d7867d4

Please sign in to comment.