From cff894183660e222605b945d841a3cb580082201 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 9 Nov 2012 16:02:08 +0000 Subject: 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 --- src/Fl_BMP_Image.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Fl_BMP_Image.cxx') diff --git a/src/Fl_BMP_Image.cxx b/src/Fl_BMP_Image.cxx index f9dd18b38..8542763be 100644 --- a/src/Fl_BMP_Image.cxx +++ b/src/Fl_BMP_Image.cxx @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -187,6 +188,11 @@ Fl_BMP_Image::Fl_BMP_Image(const char *bmp) // I - File to read d(bDepth); if (offbits) fseek(fp, offbits, SEEK_SET); + if (((size_t)w()) * h() * d() > max_size() ) { + Fl::warning("BMP file \"%s\" is too large!\n", bmp); + fclose(fp); + return; + } array = new uchar[w() * h() * d()]; alloc_array = 1; -- cgit v1.2.3