In png_set_error_fn the user can set a custom error_ptr. The purpose of this error_ptr is undocumented. I assume it to be a 'userdata' pointer for the error functions but this is unclear from the documentation.
We also pass the library version, optional
pointers to error handling functions, and a pointer to a data struct for
use by the error functions, if necessary (the pointer and functions can
be NULL if the default error handlers are to be used).
contrib/gregbook/ readpng2.c and writepng.c, contrib/libtests/pngvalid.c,
and several other programs in the contrib directory have of examples of png_get_error_ptr() usage.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Maybe a pointer to this info should be included in the documentation of png_set_error_fn() ? Because I did not find the above documentation (I tried grepping through the docs for 'error_ptr' but since that exact phrase does not occur in this text I had not found it.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In libpng-1.6.30beta01 I'm adding, in the description of
the error_fn in libpng.3 and libpng-manual.txt,
+Then, within your user_error_fn or user_warning_fn, you can retrieve
+the error_ptr if you need it, by calling
+
+ png_voidp error_ptr = png_get_error_ptr(png_ptr);
+
Last edit: Glenn Randers-Pehrson 2017-03-28
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The libpng manpage has this:
contrib/gregbook/ readpng2.c and writepng.c, contrib/libtests/pngvalid.c,
and several other programs in the contrib directory have of examples of png_get_error_ptr() usage.
Maybe a pointer to this info should be included in the documentation of png_set_error_fn() ? Because I did not find the above documentation (I tried grepping through the docs for 'error_ptr' but since that exact phrase does not occur in this text I had not found it.)
In libpng-1.6.30beta01 I'm adding, in the description of
the error_fn in libpng.3 and libpng-manual.txt,
+Then, within your user_error_fn or user_warning_fn, you can retrieve
+the error_ptr if you need it, by calling
+
+ png_voidp error_ptr = png_get_error_ptr(png_ptr);
+
Last edit: Glenn Randers-Pehrson 2017-03-28
Fixed in libpng-1.6.30