From c8d408b42890c79b57c93eb7ecdf7b7fd2a271ea Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Sat, 18 Sep 2021 13:52:08 +0200 Subject: Check the status of new Cairo surfaces properly --- fastiv-view.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fastiv-view.c b/fastiv-view.c index 7a29321..a7bf0cd 100644 --- a/fastiv-view.c +++ b/fastiv-view.c @@ -229,8 +229,10 @@ open_wuffs(wuffs_base__image_decoder *dec, cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); - if (!surface) { - set_error(error, "failed to allocate an image surface"); + cairo_status_t surface_status = cairo_surface_status(surface); + if (surface_status != CAIRO_STATUS_SUCCESS) { + set_error(error, cairo_status_to_string(surface_status)); + cairo_surface_destroy(surface); free(workbuf.ptr); return NULL; } @@ -336,8 +338,10 @@ open_libjpeg_turbo(const gchar *data, gsize len, GError **error) cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); - if (!surface) { - set_error(error, "failed to allocate an image surface"); + cairo_status_t surface_status = cairo_surface_status(surface); + if (surface_status != CAIRO_STATUS_SUCCESS) { + set_error(error, cairo_status_to_string(surface_status)); + cairo_surface_destroy(surface); tjDestroy(dec); return NULL; } @@ -444,8 +448,10 @@ open_libraw(const gchar *data, gsize len, GError **error) int width = image->width, height = image->height; cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); - if (!surface) { - set_error(error, "failed to allocate an image surface"); + cairo_status_t surface_status = cairo_surface_status(surface); + if (surface_status != CAIRO_STATUS_SUCCESS) { + set_error(error, cairo_status_to_string(surface_status)); + cairo_surface_destroy(surface); libraw_dcraw_clear_mem(image); libraw_close(iprc); return NULL; -- cgit v1.2.3-70-g09d2