summaryrefslogtreecommitdiff
path: root/src/Fl_PNG_Image.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2012-11-09 16:02:08 +0000
committerManolo Gouy <Manolo>2012-11-09 16:02:08 +0000
commitcff894183660e222605b945d841a3cb580082201 (patch)
treee5f6e96ecd4a03e29753703b379e4c51bf6437ff /src/Fl_PNG_Image.cxx
parent8701434312c150b4c07074feee008129c775ad71 (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_PNG_Image.cxx')
-rw-r--r--src/Fl_PNG_Image.cxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Fl_PNG_Image.cxx b/src/Fl_PNG_Image.cxx
index 5a295c87f..d6261c9ce 100644
--- a/src/Fl_PNG_Image.cxx
+++ b/src/Fl_PNG_Image.cxx
@@ -130,7 +130,7 @@ void Fl_PNG_Image::load_png_(const char *name_png, const unsigned char *buffer_p
{
png_destroy_read_struct(&pp, &info, NULL);
if (!from_memory) fclose(fp);
- Fl::warning("PNG file or data \"%s\" contains errors!\n", name_png);
+ Fl::warning("PNG file or data \"%s\" is too large or contains errors!\n", name_png);
return;
}
@@ -178,6 +178,7 @@ void Fl_PNG_Image::load_png_(const char *name_png, const unsigned char *buffer_p
png_set_tRNS_to_alpha(pp);
# endif // HAVE_PNG_GET_VALID && HAVE_PNG_SET_TRNS_TO_ALPHA
+ if (((size_t)w()) * h() * d() > max_size() ) longjmp(png_jmpbuf(pp), 1);
array = new uchar[w() * h() * d()];
alloc_array = 1;