mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
-MFB: libgd #94, imagecreatefromxbm can crash if gdImageCreate fails
This commit is contained in:
parent
fb4967900d
commit
3b8fc04079
@ -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';
|
||||
|
19
ext/gd/tests/libgd00094.phpt
Normal file
19
ext/gd/tests/libgd00094.phpt
Normal 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)
|
||||
|
3
ext/gd/tests/libgd00094.xbm
Normal file
3
ext/gd/tests/libgd00094.xbm
Normal file
@ -0,0 +1,3 @@
|
||||
#define width 255
|
||||
#define height 1073741824
|
||||
static unsigned char bla = {
|
Loading…
Reference in New Issue
Block a user