[英]CImg throws an exception in Debug mode, works fine in Release
My program is written in C++. 我的程序是用C ++编写的。 I use Visual Studio 2017. 我使用Visual Studio 2017。
My code compiles and runs correctly in Release mode, but throws exception in Debug mode : 我的代码在Release模式下编译并正确运行,但在Debug模式下抛出异常 :
Unhandled exception at 0x00007FF9A4EAD428 (ucrtbase.dll) in MyAssemblyName.exe: An invalid parameter was passed to a function that considers invalid parameters fatal. MyAssemblyName.exe中0x00007FF9A4EAD428(ucrtbase.dll)的未处理异常:无效参数传递给认为无效参数致命的函数。
This exception is thrown in the img.assign()
function 在img.assign()
函数中抛出此异常
CImg<unsigned char> img;
try {
img.assign(picPath.c_str());
}
catch (CImgException) {
// ...
}
In CImg, this is the code being executed: 在CImg中,这是正在执行的代码:
std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
struct jpeg_decompress_struct cinfo;
struct _cimg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr.original);
jerr.original.error_exit = _cimg_jpeg_error_exit;
if (setjmp(jerr.setjmp_buffer)) { // JPEG error
if (!file) cimg::fclose(nfile);
throw CImgIOException(_cimg_instance
"load_jpeg(): Error message returned by libjpeg: %s.",
cimg_instance,jerr.message);
}
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo,nfile);
jpeg_read_header(&cinfo,TRUE);
jpeg_start_decompress(&cinfo);
The exception is thrown when executing jpeg_read_header()
. 执行jpeg_read_header()
时抛出异常。
Why is this happening? 为什么会这样? Why only in Debug mode, not Release? 为什么只在Debug模式下,而不是Release?
我已经根据此答案更新了jpeg库,问题消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.