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: swaywm#6531
  • Loading branch information
emersion authored and RagnarGrootKoerkamp committed Mar 29, 2022
1 parent 46b296a commit 67aebe3
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 67aebe3

Please sign in to comment.