mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Merge branch 'PHP-8.4'
This commit is contained in:
commit
77d748617a
2 changed files with 33 additions and 1 deletions
|
@ -3187,7 +3187,11 @@ int gdImagePaletteToTrueColor(gdImagePtr src)
|
|||
const unsigned int sy = gdImageSY(src);
|
||||
const unsigned int sx = gdImageSX(src);
|
||||
|
||||
src->tpixels = (int **) gdMalloc(sizeof(int *) * sy);
|
||||
// Note: do not revert back to gdMalloc() below ; reason here,
|
||||
// due to a bug with a certain memory_limit INI value treshold,
|
||||
// imagepalettetotruecolor crashes with even unrelated ZendMM allocations.
|
||||
// See GH-17772 for an use case.
|
||||
src->tpixels = (int **) gdCalloc(sizeof(int *), sy);
|
||||
if (src->tpixels == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
|
28
ext/gd/tests/gh17772.phpt
Normal file
28
ext/gd/tests/gh17772.phpt
Normal file
|
@ -0,0 +1,28 @@
|
|||
--TEST--
|
||||
GH-17772 (imagepalettetotruecolor segfault on image deallocation)
|
||||
--EXTENSIONS--
|
||||
gd
|
||||
--INI--
|
||||
memory_limit=2M
|
||||
--CREDITS--
|
||||
YuanchengJiang
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!GD_BUNDLED) die("skip requires bundled GD library");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
function setStyleAndThickness($im, $color, $thickness)
|
||||
{
|
||||
$arr = [];
|
||||
$i = 0;
|
||||
while ($i < 16 * $thickness) {
|
||||
$arer[$i++] = $color;
|
||||
}
|
||||
}
|
||||
$im = imagecreate(800, 800);
|
||||
setStyleAndThickness($im, 0, 6);
|
||||
imagepalettetotruecolor($im);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
|
Loading…
Add table
Add a link
Reference in a new issue