mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00
Merge branch 'PHP-7.0'
* PHP-7.0: fix #72512, invalid read or write for palette image when invalid transparent index is used
This commit is contained in:
commit
6434fc9d2b
3 changed files with 32 additions and 6 deletions
|
@ -597,15 +597,18 @@ void gdImageColorDeallocate (gdImagePtr im, int color)
|
|||
|
||||
void gdImageColorTransparent (gdImagePtr im, int color)
|
||||
{
|
||||
if (color < 0) {
|
||||
return;
|
||||
}
|
||||
if (!im->trueColor) {
|
||||
if((color >= im->colorsTotal)) {
|
||||
return;
|
||||
}
|
||||
/* Make the old transparent color opaque again */
|
||||
if (im->transparent != -1) {
|
||||
im->alpha[im->transparent] = gdAlphaOpaque;
|
||||
}
|
||||
if (color > -1 && color < im->colorsTotal && color < gdMaxColors) {
|
||||
im->alpha[color] = gdAlphaTransparent;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
im->alpha[color] = gdAlphaTransparent;
|
||||
}
|
||||
im->transparent = color;
|
||||
}
|
||||
|
|
|
@ -1244,7 +1244,13 @@ static gdImagePtr gdImageScaleBilinearPalette(gdImagePtr im, const unsigned int
|
|||
if (new_img == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
new_img->transparent = gdTrueColorAlpha(im->red[transparent], im->green[transparent], im->blue[transparent], im->alpha[transparent]);
|
||||
|
||||
if (transparent < 0) {
|
||||
/* uninitialized */
|
||||
new_img->transparent = -1;
|
||||
} else {
|
||||
new_img->transparent = gdTrueColorAlpha(im->red[transparent], im->green[transparent], im->blue[transparent], im->alpha[transparent]);
|
||||
}
|
||||
|
||||
for (i=0; i < _height; i++) {
|
||||
long j;
|
||||
|
|
17
ext/gd/tests/bug72512.phpt
Normal file
17
ext/gd/tests/bug72512.phpt
Normal file
|
@ -0,0 +1,17 @@
|
|||
--TEST--
|
||||
Bug #19366 (gdimagefill() function crashes (fixed in bundled libgd))
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die("skip gd extension not available\n");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$img = imagecreatetruecolor(100, 100);
|
||||
imagecolortransparent($img, -1000000);
|
||||
imagetruecolortopalette($img, TRUE, 3);
|
||||
imagecolortransparent($img, 9);
|
||||
echo "OK";
|
||||
?>
|
||||
--EXPECT--
|
||||
OK
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue