com php-src: Fix #69024: imagescale segfault with palette based image: ext/gd/libgd/gd_interpolation.c ext/gd/tests/bug690 24.phpt

From: Date: Mon, 13 Jul 2015 13:48:48 +0000
Subject: com php-src: Fix #69024: imagescale segfault with palette based image: ext/gd/libgd/gd_interpolation.c ext/gd/tests/bug690 24.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87957@lists.php.net to get a copy of this message
Commit: fa53d8463f2566f5e4cdedda7a2662f74a7dcd7c Author: Christoph M. Becker <cmb@php.net> Mon, 13 Jul 2015 15:43:16 +0200 Parents: 2939bce9f3115f52612fc14fcadf797a659fd3ed Branches: PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fa53d8463f2566f5e4cdedda7a2662f74a7dcd7c Log: 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] <https://github.com/libgd/libgd/commit/723ea520bed3b5854df87393c687323d3930edf3> Bugs: https://bugs.php.net/69024 Changed paths: M ext/gd/libgd/gd_interpolation.c A ext/gd/tests/bug69024.phpt Diff: diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index c1bf061..f9c8f88 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 0000000..f2113fc --- /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

« previous php.cvs (#87957) next »