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
This commit is contained in:
Matthias Melcher 2005-07-11 20:31:59 +00:00
parent 9e28a66b1f
commit 22986c92c4
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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,8 +120,12 @@ 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);
jpeg_destroy_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);

View File

@ -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();