Add new comment

0.19.0-Beta1: small fix in thumbnail generation code

Two changes here:

1) use client_data structure, rather than assume the cinfo->err structure has extra space after it which holds the longjmp/setjmp buffer. (This is not a fix but a cleanup.)
2) make sure to return an error code in the event the thumbnail decoding fails.

By the way, is this the right place to submit bug reports?

--- src/libraw_cxx.cpp.dist 2018-02-27 22:35:04.000000000 -0800
+++ src/libraw_cxx.cpp 2018-03-18 23:38:39.000000000 -0700
@@ -4171,7 +4171,7 @@

static void jpegErrorExit(j_common_ptr cinfo)
{
- jpegErrorManager *myerr = (jpegErrorManager *)cinfo->err;
+ jpegErrorManager *myerr = (jpegErrorManager *)cinfo->client_data;
longjmp(myerr->setjmp_buffer, 1);
}
#endif
@@ -4238,6 +4238,7 @@
{
jpegErrorManager jerr;
struct jpeg_decompress_struct cinfo;
+ cinfo.client_data = &jerr;
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = jpegErrorExit;
if (setjmp(jerr.setjmp_buffer))
@@ -4245,6 +4246,7 @@
err2:
jpeg_destroy_decompress(&cinfo);
T.tcolors = 3;
+ return LIBRAW_DATA_ERROR;
}
jpeg_create_decompress(&cinfo);
jpeg_mem_src(&cinfo, (unsigned char *)T.thumb, T.tlength);

Forums: