[cairo] [PATCH] Generate better error message when loading invalid PNGs
Cyril Roelandt
tipecaml at gmail.com
Fri Mar 25 20:24:15 UTC 2016
On 03/25/2016 08:24 PM, Bill Spitzak wrote:
> I really don't see this as better, because now you are relying on local
> code arriving at exactly the same "is this a png file" conclusion as
> libpng. Also there are lots of other errors that are not no-memory.
>
> Grepping libpng for png_error, I think perhaps this code will pick the most
> appropriate error:
>
> if (strstr(message, "alloc") || strstr(message, "OOM") ||
> strstr(message, "memory")
> return CAIRO_STATUS_NO_MEMORY;
> else
> return CAIRO_STATUS_READ_ERROR;
>
Why wouldn't we grep for "Not a PNG" as well? Also, Uli stated that it
might not be the best idea to rely on the error messages from libpng,
since they might change. WDYT?
Using png_sig_cmp allow us to be perfectly sure that the issue is with
the file/stream, and to return an appropriate error code to the user,
without gambling.
Cyril.
More information about the cairo
mailing list