Re: [PATCH] Generate better error message when loading invalid PNGs
Cyril Roelandt <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
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. -- cairo mailing list [email protected] https://lists.cairographics.org/mailman/listinfo/cairo