Skip to content

Commit 7b2c226

Browse files
pierrejoyeweltling
authored andcommitted
Fixed bug #72512 gdImageTrueColorToPaletteBody allows arbitrary write/read access
1 parent cab1c3b commit 7b2c226

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ext/gd/libgd/gd.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,15 +599,18 @@ void gdImageColorDeallocate (gdImagePtr im, int color)
599599

600600
void gdImageColorTransparent (gdImagePtr im, int color)
601601
{
602+
if (color < 0) {
603+
return;
604+
}
605+
602606
if (!im->trueColor) {
607+
if((color >= gdMaxColors)) {
608+
return;
609+
}
603610
if (im->transparent != -1) {
604611
im->alpha[im->transparent] = gdAlphaOpaque;
605612
}
606-
if (color > -1 && color < im->colorsTotal && color < gdMaxColors) {
607-
im->alpha[color] = gdAlphaTransparent;
608-
} else {
609-
return;
610-
}
613+
im->alpha[color] = gdAlphaTransparent;
611614
}
612615
im->transparent = color;
613616
}

0 commit comments

Comments
 (0)