File php-5.1.2-phpbug-37346.patch of Package php

--- ext/gd/libgd/gd_gif_in.c	2005/09/24 14:39:16	1.5.4.2
+++ ext/gd/libgd/gd_gif_in.c	2006/05/08 11:56:14	1.5.4.4
@@ -44,7 +44,7 @@
 #define LOCALCOLORMAP  0x80
 #define BitSet(byte, bit)      (((byte) & (bit)) == (bit))
 
-#define        ReadOK(file,buffer,len) (gdGetBuf(buffer, len, file) != 0)
+#define        ReadOK(file,buffer,len) (gdGetBuf(buffer, len, file) > 0)
 
 #define LM_to_uint(a,b)                        (((b)<<8)|(a))
 
@@ -147,6 +147,9 @@
        Background      = buf[5];
        AspectRatio     = buf[6];
 
+		imw = LM_to_uint(buf[0],buf[1]);
+		imh = LM_to_uint(buf[2],buf[3]);
+
        if (BitSet(buf[4], LOCALCOLORMAP)) {    /* Global Colormap */
                if (ReadColorMap(fd, BitPixel, ColorMap)) {
 			return 0;
@@ -182,16 +185,18 @@
 
                bitPixel = 1<<((buf[8]&0x07)+1);
 
-               imw = LM_to_uint(buf[4],buf[5]);
-               imh = LM_to_uint(buf[6],buf[7]);
-	       if (!(im = gdImageCreate(imw, imh))) {
-			 return 0;
-	       }
-               im->interlace = BitSet(buf[8], INTERLACE);
+
                if (! useGlobalColormap) {
                        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); */
openSUSE Build Service is sponsored by