From db0939a599520406e94fda2ffbec5ce1c3c40a04 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 15 Sep 2003 23:52:38 +0000 Subject: Add error handlers to JPEG and PNG image classes so the corresponding libraries don't exit the app with a bad file (STR #168) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3105 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_JPEG_Image.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/Fl_JPEG_Image.cxx') diff --git a/src/Fl_JPEG_Image.cxx b/src/Fl_JPEG_Image.cxx index 2898288ef..1752b1c6e 100644 --- a/src/Fl_JPEG_Image.cxx +++ b/src/Fl_JPEG_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_JPEG_Image.cxx,v 1.1.2.7 2003/01/30 21:42:02 easysw Exp $" +// "$Id: Fl_JPEG_Image.cxx,v 1.1.2.8 2003/09/15 23:52:37 easysw Exp $" // // Fl_JPEG_Image routines. // @@ -55,6 +55,17 @@ extern "C" } +// +// Error handler for JPEG files... +// + +static void +jpeg_error_handler(j_common_ptr) +{ + return; +} + + // // 'Fl_JPEG_Image::Fl_JPEG_Image()' - Load a JPEG image file. // @@ -71,6 +82,8 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load if ((fp = fopen(jpeg, "rb")) == NULL) return; cinfo.err = jpeg_std_error(&jerr); + jerr.error_exit = jpeg_error_handler; + jpeg_create_decompress(&cinfo); jpeg_stdio_src(&cinfo, fp); jpeg_read_header(&cinfo, 1); @@ -107,5 +120,5 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load } // -// End of "$Id: Fl_JPEG_Image.cxx,v 1.1.2.7 2003/01/30 21:42:02 easysw Exp $". +// End of "$Id: Fl_JPEG_Image.cxx,v 1.1.2.8 2003/09/15 23:52:37 easysw Exp $". // -- cgit v1.2.3