diff src/dgif_lib.c @ 114:8619ce7e4c50 r20-1b9

Import from CVS: tag r20-1b9
author cvs
date Mon, 13 Aug 2007 09:21:54 +0200
parents 54cc21c15cbb
children e292c9648bb9
line wrap: on
line diff
--- a/src/dgif_lib.c	Mon Aug 13 09:20:50 2007 +0200
+++ b/src/dgif_lib.c	Mon Aug 13 09:21:54 2007 +0200
@@ -915,6 +915,7 @@
     SavedImage *sp;
     ExtensionBlock *ep;
     GifByteType *ExtData;
+    int ExtCode;
 
     /* Some versions of malloc dislike 0-length requests */
     GifFile->SavedImages = (SavedImage *)xmalloc(sizeof(SavedImage));
@@ -941,7 +942,12 @@
 		break;
 
 	    case EXTENSION_RECORD_TYPE:
-
+	        /* This code fails if no image_desc record has been read
+		   yet.  I don't know if that's legal, but I've seen GIFs
+		   that start with an extension record.  XEmacs doesn't use
+		   the extension records anyway, so we'll just ignore them.
+		   - dkindred@cs.cmu.edu */
+#if 0
 		if (DGifGetExtension(GifFile,&sp->Function,&ExtData)==GIF_ERROR)
 		    return(GIF_ERROR);
 		else
@@ -965,6 +971,17 @@
 			memcpy(ep->Bytes,ExtData,ep->ByteCount * sizeof(char));
 		    }
 		}
+#else
+	        /* Skip any extension blocks in the file. */
+	        if (DGifGetExtension (GifFile, &ExtCode, &ExtData) 
+		    == GIF_ERROR)
+		    return GIF_ERROR;
+
+		while (ExtData != NULL) {
+		    if (DGifGetExtensionNext (GifFile, &ExtData) == GIF_ERROR)
+		        return GIF_ERROR;
+		}
+#endif
 		break;
 
 	    case TERMINATE_RECORD_TYPE: