Boost C++ Libraries: Ticket #3116: boost GIL doesn't properly handle JPEG errors https://svn.boost.org/trac10/ticket/3116 <p> 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. </p> <p> This is because libjpeg uses the <code>error_exit</code> handler from the current <code>jpeg_error_mgr</code> to signal an error. The default <code>error_exit</code> handler simply prints a message to stderr and calls <code>exit(EXIT_FAILURE)</code>. However, in order to properly handle this error one needs to override this <code>error_exit handler</code>. Attached patch does just that, using the same error message, though instead, it uses that message as a description for an <code>io_error(const char* desc)</code> generated exception (<code>std::ios_base::failure</code>). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3116 Trac 1.4.3 Giel van Schijndel <me@…> Sun, 31 May 2009 23:13:46 GMT attachment set https://svn.boost.org/trac10/ticket/3116 https://svn.boost.org/trac10/ticket/3116 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">jpeg-io_error-exception.patch</span> </li> </ul> <p> Turn JPEG errors into exceptions </p> Ticket Giel van Schijndel <me@…> Wed, 03 Jun 2009 10:19:57 GMT cc set https://svn.boost.org/trac10/ticket/3116#comment:1 https://svn.boost.org/trac10/ticket/3116#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">me@…</span> added </li> </ul> <p> 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). </p> <p> 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. </p> Ticket mloskot <mateusz@…> Sat, 03 Oct 2009 21:40:36 GMT cc changed https://svn.boost.org/trac10/ticket/3116#comment:2 https://svn.boost.org/trac10/ticket/3116#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">mateusz@…</span> added </li> </ul> Ticket chhenning Thu, 05 Aug 2010 19:48:10 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3116#comment:3 https://svn.boost.org/trac10/ticket/3116#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> Please use new io extension. A lot of time has been there for correct error handling. </p> <p> Closing this ticket. </p> Ticket pascal@… Tue, 11 Oct 2011 02:28:09 GMT <link>https://svn.boost.org/trac10/ticket/3116#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3116#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/3116#comment:3" title="Comment 3">chhenning</a>: </p> <blockquote class="citation"> <p> Please use new io extension. A lot of time has been there for correct error handling. </p> </blockquote> <p> 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… </p> </description> <category>Ticket</category> </item> </channel> </rss>