diff options
| author | Manolo Gouy <Manolo> | 2012-11-09 16:02:08 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2012-11-09 16:02:08 +0000 |
| commit | cff894183660e222605b945d841a3cb580082201 (patch) | |
| tree | e5f6e96ecd4a03e29753703b379e4c51bf6437ff /src/Fl_JPEG_Image.cxx | |
| parent | 8701434312c150b4c07074feee008129c775ad71 (diff) | |
Fix STR#2881: the new static function Fl_RGB_Image::max_size(size) allows to control the maximum
memory size allowed when creating an Fl_RGB_Image.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9709 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_JPEG_Image.cxx')
| -rw-r--r-- | src/Fl_JPEG_Image.cxx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Fl_JPEG_Image.cxx b/src/Fl_JPEG_Image.cxx index f8e9a6192..ade8df56e 100644 --- a/src/Fl_JPEG_Image.cxx +++ b/src/Fl_JPEG_Image.cxx @@ -28,6 +28,7 @@ #include <FL/Fl_JPEG_Image.H> #include <FL/Fl_Shared_Image.H> #include <FL/fl_utf8.h> +#include <FL/Fl.H> #include <config.h> #include <stdio.h> #include <stdlib.h> @@ -126,6 +127,7 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *filename) // I - File to load if (setjmp(jerr.errhand_)) { // JPEG error handling... + Fl::warning("JPEG file \"%s\" is too large or contains errors!\n", filename); // 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) @@ -166,6 +168,7 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *filename) // I - File to load h(dinfo.output_height); d(dinfo.output_components); + if (((size_t)w()) * h() * d() > max_size() ) longjmp(jerr.errhand_, 1); array = new uchar[w() * h() * d()]; alloc_array = 1; @@ -304,6 +307,7 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *name, const unsigned char *data) if (setjmp(jerr.errhand_)) { // JPEG error handling... + Fl::warning("JPEG data is too large or contains errors!\n"); // 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) @@ -342,6 +346,7 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *name, const unsigned char *data) h(dinfo.output_height); d(dinfo.output_components); + if (((size_t)w()) * h() * d() > max_size() ) longjmp(jerr.errhand_, 1); array = new uchar[w() * h() * d()]; alloc_array = 1; |
