-MFB: libgd #94, imagecreatefromxbm can crash if gdImageCreate fails

This commit is contained in:
Mattias Bengtsson 2007-08-09 12:09:30 +00:00
parent fb4967900d
commit 3b8fc04079
3 changed files with 25 additions and 1 deletions

View File

@ -96,7 +96,9 @@ gdImagePtr gdImageCreateFromXbm(FILE * fd)
return 0;
}
im = gdImageCreate(width, height);
if(!(im = gdImageCreate(width, height))) {
return 0;
}
gdImageColorAllocate(im, 255, 255, 255);
gdImageColorAllocate(im, 0, 0, 0);
h[2] = '\0';

View File

@ -0,0 +1,19 @@
--TEST--
libgd #94 (imagecreatefromxbm can crash if gdImageCreate fails)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die("skip gd extension not available\n");
if (!GD_BUNDLED) die("skip requires bundled GD library\n");
?>
--FILE--
<?php
$im = imagecreatefromxbm(dirname(__FILE__) . '/libgd00094.xbm');
var_dump($im);
?>
--EXPECTF--
Warning: imagecreatefromxbm(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
in %slibgd00094.php on line %d
Warning: imagecreatefromxbm(): '%slibgd00094.xbm' is not a valid XBM file in %slibgd00094.php on line %d
bool(false)

View File

@ -0,0 +1,3 @@
#define width 255
#define height 1073741824
static unsigned char bla = {