Browse Source

Fix #69024: imagescale segfault with palette based image

imagescale(..., IMG_BICUBIC) is not supposed to work with palette images, so we
fix that by converting to true color if necessary. Basically the same fix has
already been applied to the external libgd[1].

[1] <723ea520be>
pull/1417/head
Christoph M. Becker 11 years ago
parent
commit
bccbd2df21
  1. 5
      ext/gd/libgd/gd_interpolation.c
  2. 15
      ext/gd/tests/bug69024.phpt

5
ext/gd/libgd/gd_interpolation.c

@ -1059,6 +1059,11 @@ gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_widt
gdImagePtr tmp_im;
gdImagePtr dst;
/* Convert to truecolor if it isn't; this code requires it. */
if (!src->trueColor) {
gdImagePaletteToTrueColor(src);
}
tmp_im = gdImageCreateTrueColor(new_width, src_height);
if (tmp_im == NULL) {
return NULL;

15
ext/gd/tests/bug69024.phpt

@ -0,0 +1,15 @@
--TEST--
Bug #69024 (imagescale segfault with palette based image)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
?>
--FILE--
<?php
$im = imagecreate(256, 256);
imagescale($im, 32, 32, IMG_BICUBIC);
imagedestroy($im);
echo "done\n";
?>
--EXPECT--
done
Loading…
Cancel
Save