diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2005-07-11 20:31:59 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2005-07-11 20:31:59 +0000 |
| commit | 22986c92c48ed7b9e828e849bb85684269cc6232 (patch) | |
| tree | 026257c8a76c624c8497864dce37df13a1870658 /src/Fl_JPEG_Image.cxx | |
| parent | 9e28a66b1f58f51a1432e505b2019da82cc30161 (diff) | |
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
Diffstat (limited to 'src/Fl_JPEG_Image.cxx')
| -rw-r--r-- | src/Fl_JPEG_Image.cxx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Fl_JPEG_Image.cxx b/src/Fl_JPEG_Image.cxx index d690e2afa..ee3899853 100644 --- a/src/Fl_JPEG_Image.cxx +++ b/src/Fl_JPEG_Image.cxx @@ -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); |
