Browse Source

STR #915: fixed hang on corrupt jpegs by giving a maximum of 10 chances for jpeg lib to clean up on damaged file reads.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4410 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
pull/168/head
Matthias Melcher 20 years ago
parent
commit
22986c92c4
  1. 1
      CHANGES
  2. 8
      src/Fl_JPEG_Image.cxx
  3. 2
      test/file_chooser.cxx

1
CHANGES

@ -2,6 +2,7 @@ CHANGES IN FLTK 1.1.7 @@ -2,6 +2,7 @@ CHANGES IN FLTK 1.1.7
- Documentation fixes (STR #648, STR #692, STR #730, STR
#744, STR #745)
- Fixed hang on corrupt jpeg (STR #915)
- Added symbols 'refresh', 'reload', 'undo', and 'redo'.
- Fixed focus loss on Fl_Window:resize()
- Fl::delete_widget would hang fl_wait after deleting the

8
src/Fl_JPEG_Image.cxx

@ -101,6 +101,8 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load @@ -101,6 +101,8 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load
jpeg_decompress_struct dinfo; // Decompressor info
fl_jpeg_error_mgr jerr; // Error handler info
JSAMPROW row; // Sample row pointer
int max_finish_decompress_err = 10; // give up after too many errors
int max_destroy_decompress_err = 10; // give up after too many errors
// Clear data...
@ -118,7 +120,11 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load @@ -118,7 +120,11 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load
if (setjmp(jerr.errhand_))
{
// JPEG error handling...
if (array) jpeg_finish_decompress(&dinfo);
// if any of the cleanup routines hits another error, we would end up
// in a loop. So instead, we decrement max_err for some upper cleanup limit.
if ( (max_finish_decompress_err-- > 0) && array)
jpeg_finish_decompress(&dinfo);
if ( max_destroy_decompress_err-- > 0)
jpeg_destroy_decompress(&dinfo);
fclose(fp);

2
test/file_chooser.cxx

@ -133,7 +133,7 @@ main(int argc, // I - Number of command-line arguments @@ -133,7 +133,7 @@ main(int argc, // I - Number of command-line arguments
window->resizable(files);
window->end();
window->show();
window->show(1, argv);
Fl::run();

Loading…
Cancel
Save