Windows build crashes when trying to load a corrupted jpg, fixes #5366

This commit is contained in:
Ingo Weyrich 2019-07-06 12:58:53 +02:00
parent 6fa533c40b
commit 0f09559413
2 changed files with 8 additions and 0 deletions

View File

@ -575,7 +575,11 @@ int ImageIO::loadJPEG (const Glib::ustring &fname)
my_jpeg_stdio_src (&cinfo, file);
#if defined( WIN32 ) && defined( __x86_64__ ) && !defined(__clang__)
if ( __builtin_setjmp((reinterpret_cast<rt_jpeg_error_mgr*>(cinfo.src))->error_jmp_buf) == 0 ) {
#else
if ( setjmp((reinterpret_cast<rt_jpeg_error_mgr*>(cinfo.src))->error_jmp_buf) == 0 ) {
#endif
if (pl) {
pl->setProgressStr ("PROGRESSBAR_LOADJPEG");
pl->setProgress (0.0);

View File

@ -245,7 +245,11 @@ my_error_exit (j_common_ptr cinfo)
j_decompress_ptr dinfo = (j_decompress_ptr)cinfo;
// longjmp (((rt_jpeg_error_mgr*)(dinfo->src))->error_jmp_buf, 1);
#if defined( WIN32 ) && defined( __x86_64__ ) && !defined(__clang__)
__builtin_longjmp ((reinterpret_cast<rt_jpeg_error_mgr*>(dinfo->src)) ->error_jmp_buf, 1);
#else
longjmp ((reinterpret_cast<rt_jpeg_error_mgr*>(dinfo->src)) ->error_jmp_buf, 1);
#endif
}