summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/gd/libgd/gd_interpolation.c5
-rw-r--r--ext/gd/tests/bug69024.phpt15
2 files changed, 20 insertions, 0 deletions
diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c
index c1bf061e0b..f9c8f88e70 100644
--- a/ext/gd/libgd/gd_interpolation.c
+++ b/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;
diff --git a/ext/gd/tests/bug69024.phpt b/ext/gd/tests/bug69024.phpt
new file mode 100644
index 0000000000..f2113fc44f
--- /dev/null
+++ b/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