DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2881
Version: 1.3-current
Fix Version: 1.4-feature


Attached file "2881.patch"...


Link: http://www.fltk.org/str.php?L2881
Version: 1.3-current
Fix Version: 1.4-feature
Index: src/Fl_PNG_Image.cxx
===================================================================
--- src/Fl_PNG_Image.cxx        (revision 9572)
+++ src/Fl_PNG_Image.cxx        (working copy)
@@ -33,6 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <FL/fl_utf8.h>
+#include <new>
 
 #if defined(HAVE_LIBPNG) && defined(HAVE_LIBZ)
 extern "C"
@@ -130,7 +131,7 @@
   {
     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,7 +179,8 @@
     png_set_tRNS_to_alpha(pp);
 #  endif // HAVE_PNG_GET_VALID && HAVE_PNG_SET_TRNS_TO_ALPHA
 
-  array = new uchar[w() * h() * d()];
+  array = new(std::nothrow) uchar[w() * h() * d()];
+  if (!array) longjmp(png_jmpbuf(pp), 1);
   alloc_array = 1;
 
   // Allocate pointers...
Index: src/Fl_JPEG_Image.cxx
===================================================================
--- src/Fl_JPEG_Image.cxx       (revision 9572)
+++ src/Fl_JPEG_Image.cxx       (working copy)
@@ -32,6 +32,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <setjmp.h>
+#include <new>
 
 
 // Some releases of the Cygwin JPEG libraries don't have a correctly
@@ -166,7 +167,8 @@
   h(dinfo.output_height);
   d(dinfo.output_components);
   
-  array = new uchar[w() * h() * d()];
+  array = new(std::nothrow) uchar[w() * h() * d()];
+  if (!array) longjmp(jerr.errhand_, 1);
   alloc_array = 1;
   
   jpeg_start_decompress(&dinfo);
@@ -342,7 +344,8 @@
   h(dinfo.output_height);
   d(dinfo.output_components);
   
-  array = new uchar[w() * h() * d()];
+  array = new(std::nothrow) uchar[w() * h() * d()];
+  if (!array) longjmp(jerr.errhand_, 1);
   alloc_array = 1;
   
   jpeg_start_decompress(&dinfo);
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to