summaryrefslogtreecommitdiff
path: root/src/Fl_PNM_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_PNM_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_PNM_Image.cxx')
-rw-r--r--src/Fl_PNM_Image.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Fl_PNM_Image.cxx b/src/Fl_PNM_Image.cxx
index eb4c8b7ee..bfd97d65d 100644
--- a/src/Fl_PNM_Image.cxx
+++ b/src/Fl_PNM_Image.cxx
@@ -119,6 +119,11 @@ Fl_PNM_Image::Fl_PNM_Image(const char *name) // I - File to read
// printf("%s = %dx%dx%d\n", name, w(), h(), d());
+ if (((size_t)w()) * h() * d() > max_size() ) {
+ Fl::warning("PNM file \"%s\" is too large!\n", name);
+ fclose(fp);
+ return;
+ }
array = new uchar[w() * h() * d()];
alloc_array = 1;