summaryrefslogtreecommitdiff
path: root/src/Fl_JPEG_Image.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2004-12-16 21:38:24 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2004-12-16 21:38:24 +0000
commit3387edd24796eeb1c7d4a11a9bb7147493c83e58 (patch)
tree6ef8dc2e875d614e163de871dd89ec3ced49a8a5 /src/Fl_JPEG_Image.cxx
parentf912892305a5a8749bd8caa560d88e889e70eccc (diff)
Fl_JPEG_Image did not correctly handle errors reported by the
JPEG library (STR #652) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3946 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_JPEG_Image.cxx')
-rw-r--r--src/Fl_JPEG_Image.cxx27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/Fl_JPEG_Image.cxx b/src/Fl_JPEG_Image.cxx
index c8fa0a92f..403a20978 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.10 2004/04/11 04:38:57 easysw Exp $"
+// "$Id: Fl_JPEG_Image.cxx,v 1.1.2.11 2004/12/16 21:38:24 easysw Exp $"
//
// Fl_JPEG_Image routines.
//
@@ -85,11 +85,14 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load
cinfo.err = jpeg_std_error(&jerr);
jerr.error_exit = jpeg_error_handler;
+ jerr.output_message = jpeg_error_handler;
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, fp);
jpeg_read_header(&cinfo, 1);
+ if (cinfo.err->msg_code) goto error_return;
+
cinfo.quantize_colors = (boolean)FALSE;
cinfo.out_color_space = JCS_RGB;
cinfo.out_color_components = 3;
@@ -108,6 +111,8 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load
while (cinfo.output_scanline < cinfo.output_height)
{
+ if (cinfo.err->msg_code) goto error_return;
+
row = (JSAMPROW)(array +
cinfo.output_scanline * cinfo.output_width *
cinfo.output_components);
@@ -118,9 +123,27 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load
jpeg_destroy_decompress(&cinfo);
fclose(fp);
+
+ // JPEG error handling...
+ error_return:
+
+ if (array) jpeg_finish_decompress(&cinfo);
+ jpeg_destroy_decompress(&cinfo);
+
+ fclose(fp);
+
+ if (array) {
+ w(0);
+ h(0);
+ d(0);
+
+ delete[] array;
+ array = 0;
+ alloc_array = 0;
+ }
#endif // HAVE_LIBJPEG
}
//
-// End of "$Id: Fl_JPEG_Image.cxx,v 1.1.2.10 2004/04/11 04:38:57 easysw Exp $".
+// End of "$Id: Fl_JPEG_Image.cxx,v 1.1.2.11 2004/12/16 21:38:24 easysw Exp $".
//