diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-09-18 13:52:08 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-09-18 13:52:52 +0200 |
commit | c8d408b42890c79b57c93eb7ecdf7b7fd2a271ea (patch) | |
tree | a0480b0aa4c6aa2eab021a371b4350409173eb96 | |
parent | aae6fd4d8baead50ef95793ba0b9b3433846a609 (diff) | |
download | fiv-c8d408b42890c79b57c93eb7ecdf7b7fd2a271ea.tar.gz fiv-c8d408b42890c79b57c93eb7ecdf7b7fd2a271ea.tar.xz fiv-c8d408b42890c79b57c93eb7ecdf7b7fd2a271ea.zip |
Check the status of new Cairo surfaces properly
-rw-r--r-- | fastiv-view.c | 18 |
1 files 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; |