diff options
author | Uli Schlachter <psychon@znc.in> | 2023-10-31 14:54:06 +0100 |
---|---|---|
committer | Uli Schlachter <psychon@znc.in> | 2023-10-31 14:54:06 +0100 |
commit | 23a643c80d435b8322d05a0bf127a324f3122333 (patch) | |
tree | be6e50bc8df2a046983b250a5cd94f6def386571 /test | |
parent | 36193ec952e68dbcf81aca408f5e1c3179135180 (diff) |
_cairo_surface_create_in_error(): Add PNG_ERROR support
Traditionally, loading a malformed PNG file with
cairo_image_surface_create_from_png() resulted in
CAIRO_STATUS_NO_MEMORY. This was apparently changed in commit
c5ee3f11b5f by adding CAIRO_STATUS_PNG_ERROR and using it for errors
returned from libpng. However, I don't see how this was supposed to
actually work.
There are a couple of error codes supported by
_cairo_surface_create_in_error(). Anything else is turned into
CAIRO_STATUS_NO_MEMORY, which is not a helpful status. For this reason,
CAIRO_STATUS_PNG_ERROR would be turned into CAIRO_STATUS_NO_MEMORY.
This commit adds support for CAIRO_STATUS_PNG_ERROR to
_cairo_surface_create_in_error() so that this error can actually be
returned to the caller.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'test')
-rw-r--r-- | test/create-from-broken-png-stream.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/test/create-from-broken-png-stream.c b/test/create-from-broken-png-stream.c index 7c02a2639..88cce0aff 100644 --- a/test/create-from-broken-png-stream.c +++ b/test/create-from-broken-png-stream.c @@ -61,13 +61,10 @@ preamble (cairo_test_context_t *ctx) surface = cairo_image_surface_create_from_png_stream (read_png_from_data, &offset); - /* XXX: The actual error is CAIRO_STATUS_PNG_ERROR, but - * _cairo_surface_create_in_error() does not support that. - */ - expected = CAIRO_STATUS_NO_MEMORY; + expected = CAIRO_STATUS_PNG_ERROR; status = cairo_surface_status (surface); cairo_surface_destroy (surface); - if (status != CAIRO_STATUS_NO_MEMORY) { + if (status != expected) { cairo_test_log (ctx, "Error: expected error %s, but got %s\n", cairo_status_to_string (expected), |