Skip to content

Commit

Permalink
Fl_JPEG_Image did not correctly handle errors reported by the
Browse files Browse the repository at this point in the history
JPEG library (STR #652)


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3946 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Dec 16, 2004
1 parent f912892 commit 3387edd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
@@ -1,5 +1,7 @@
CHANGES IN FLTK 1.1.7

- Fl_JPEG_Image did not correctly handle errors reported
by the JPEG library (STR #652)
- Fl_Menu now draws sub-menu arrows like other toolkits
and FLTK 2.0 (STR #651)
- Fixed a compiler warning in Fl_Window.H (STR #641)
Expand Down
27 changes: 25 additions & 2 deletions 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.
//
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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 $".
//

0 comments on commit 3387edd

Please sign in to comment.