#3116 closed Patches (wontfix)
boost GIL doesn't properly handle JPEG errors
Reported by: | Owned by: | Hailin Jin | |
---|---|---|---|
Milestone: | Boost 1.40.0 | Component: | gil USE GITHUB |
Version: | Boost 1.39.0 | Severity: | Problem |
Keywords: | Cc: | me@…, mateusz@… |
Description
When an error occurs during the decoding of a JPEG file (specifically its header) using jpeg_read_(dimensions|image|view) inside of libjpeg itself the program terminates.
This is because libjpeg uses the error_exit
handler from the current jpeg_error_mgr
to signal an error. The default error_exit
handler simply prints a message to stderr and calls exit(EXIT_FAILURE)
. However, in order to properly handle this error one needs to override this error_exit handler
. Attached patch does just that, using the same error message, though instead, it uses that message as a description for an io_error(const char* desc)
generated exception (std::ios_base::failure
).
Attachments (1)
Change History (5)
by , 13 years ago
Attachment: | jpeg-io_error-exception.patch added |
---|
comment:1 by , 13 years ago
Cc: | added |
---|
PS I'm not entirely sure whether my patch will work properly as it'll end up throwing an exception through C code. Until now, however, I haven't had any problems with throwing through C code though (I'm using it to determine the fileformat employed, i.e. try to load an image until one loader is successful).
The problem is that libjpeg doesn't expect error_exit to return. So another, C-way, of solving this could be by using longjmp and converting to an exception at the jump target.
comment:2 by , 13 years ago
Cc: | added |
---|
follow-up: 4 comment:3 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Please use new io extension. A lot of time has been there for correct error handling.
Closing this ticket.
comment:4 by , 11 years ago
Replying to chhenning:
Please use new io extension. A lot of time has been there for correct error handling.
Which "new extension"? In 1.46 there are still the same old JPEG/TIFF/PNG extensions. Sadly, the JPEG extension is unusable in this state…
Turn JPEG errors into exceptions