summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2016-07-04 10:35:20 +0200
committerAnatol Belski <ab@php.net>2016-07-04 10:35:20 +0200
commit7b2c22696ad44df1d26d70e15521adebd95c0399 (patch)
tree1ef08ac43e9da489d4c7bfa5e1f360ad9600a60b
parentcab1c3b3708eead315e033359d07049b23b147a3 (diff)
downloadphp-git-7b2c22696ad44df1d26d70e15521adebd95c0399.tar.gz
Fixed bug #72512 gdImageTrueColorToPaletteBody allows arbitrary write/read access
-rw-r--r--ext/gd/libgd/gd.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index 4dad95ae39..3a9577859e 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -599,15 +599,18 @@ void gdImageColorDeallocate (gdImagePtr im, int color)
void gdImageColorTransparent (gdImagePtr im, int color)
{
+ if (color < 0) {
+ return;
+ }
+
if (!im->trueColor) {
+ if((color >= gdMaxColors)) {
+ return;
+ }
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;
}