File php-5.1.2-phpbug-38112.patch of Package php
--- ext/gd/libgd/gd.c 2005/09/30 20:48:05 1.90.2.1
+++ ext/gd/libgd/gd.c 2006/08/10 18:34:22 1.90.2.2
@@ -2161,7 +2161,7 @@
for (x = 0; (x < w); x++) {
int c = gdImageGetPixel (src, srcX + x, srcY + y);
if (c != src->transparent) {
- gdImageSetPixel (dst, dstX + x, dstY + y, gdTrueColor(src->red[c], src->green[c], src->blue[c]));
+ gdImageSetPixel(dst, dstX + x, dstY + y, gdTrueColorAlpha(src->red[c], src->green[c], src->blue[c], src->alpha[c]));
}
}
}
--- ext/gd/libgd/gd_gd2.c 2005/08/18 12:54:43 1.16.4.1
+++ ext/gd/libgd/gd_gd2.c 2006/08/10 18:34:22 1.16.4.2
@@ -430,6 +430,10 @@
gdImagePtr im;
+ if (w<1 || h <1) {
+ return 0;
+ }
+
/* The next few lines are basically copied from gd2CreateFromFile
* we change the file size, so don't want to use the code directly.
* but we do need to know the file size.
--- ext/gd/libgd/gd_gif_in.c 2006/05/08 11:56:14 1.5.4.4
+++ ext/gd/libgd/gd_gif_in.c 2006/08/10 18:34:22 1.5.4.5
@@ -185,18 +185,15 @@
bitPixel = 1<<((buf[8]&0x07)+1);
+ if (!(im = gdImageCreate(imw, imh))) {
+ return 0;
+ }
+ im->interlace = BitSet(buf[8], INTERLACE);
if (! useGlobalColormap) {
- if (ReadColorMap(fd, bitPixel, localColorMap)) {
+ if (ReadColorMap(fd, bitPixel, localColorMap)) {
return 0;
}
- }
-
- if (!(im = gdImageCreate(imw, imh))) {
- return 0;
- }
- im->interlace = BitSet(buf[8], INTERLACE);
- if (! useGlobalColormap) {
ReadImage(im, fd, imw, imh, localColorMap,
BitSet(buf[8], INTERLACE));
/*1.4//imageCount != imageNumber); */
@@ -217,6 +214,10 @@
if (!im) {
return 0;
}
+ if (!im->colorsTotal) {
+ gdImageDestroy(im);
+ return 0;
+ }
/* Check for open colors at the end, so
we can reduce colorsTotal and ultimately
BitsPerPixel */
@@ -507,6 +508,18 @@
int v;
int xpos = 0, ypos = 0, pass = 0;
int i;
+
+ /*
+ ** Initialize the Compression routines
+ */
+ if (! ReadOK(fd,&c,1)) {
+ return;
+ }
+
+ if (c > MAX_LWZ_BITS) {
+ return;
+ }
+
/* Stash the color map into the image */
for (i=0; (i<gdMaxColors); i++) {
im->red[i] = cmap[CM_RED][i];
@@ -516,12 +529,7 @@
}
/* Many (perhaps most) of these colors will remain marked open. */
im->colorsTotal = gdMaxColors;
- /*
- ** Initialize the Compression routines
- */
- if (! ReadOK(fd,&c,1)) {
- return;
- }
+
if (LWZReadByte(fd, TRUE, c) < 0) {
return;
}
--- ext/gd/libgd/gd_gif_out.c 2006/03/13 21:56:38 1.1.6.1
+++ ext/gd/libgd/gd_gif_out.c 2006/08/10 18:34:22 1.1.6.2
@@ -265,9 +265,11 @@
int InitCodeSize;
int i;
GifCtx ctx;
+
+ memset(&ctx, 0, sizeof(ctx));
ctx.Interlace = GInterlace;
ctx.in_count = 1;
- memset(&ctx, 0, sizeof(ctx));
+
ColorMapSize = 1 << BitsPerPixel;
RWidth = ctx.Width = GWidth;