(U-0002195D): Add `ideographic-structure'; add `sound@ja/on'; add
[chise/xemacs-chise.git.1] / src / dgif_lib.c
index 1d08478..df67571 100644 (file)
@@ -366,10 +366,11 @@ void DGifGetExtensionNext(GifFileType *GifFile, GifByteType **Extension)
 ******************************************************************************/
 int DGifCloseFile(GifFileType *GifFile)
 {
-    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
+    GifFilePrivateType *Private;
 
     if (GifFile == NULL) return -1;
 
+    Private = (GifFilePrivateType *)GifFile->Private;
     if (!IS_READABLE(Private))
     {
        /* This file was NOT open for reading: */
@@ -740,11 +741,11 @@ void DGifSlurp(GifFileType *GifFile)
            case EXTENSION_RECORD_TYPE:
                DGifGetExtension(GifFile,&sp->Function,&ExtData);
                
-               do {
+               while (ExtData != NULL) {
                    if (AddExtensionBlock(sp, ExtData[0], ExtData+1) == GIF_ERROR)
                        GifInternError(GifFile, D_GIF_ERR_NOT_ENOUGH_MEM);
                    DGifGetExtensionNext(GifFile, &ExtData);
-               } while (ExtData != NULL);
+               }
                break;
 
            case TERMINATE_RECORD_TYPE:
@@ -930,7 +931,10 @@ ColorMapObject *MakeMapObject(int ColorCount, GifColorType *ColorMap)
 
     Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
     if (Object->Colors == (GifColorType *)NULL)
+      {
+       free (Object);
        return((ColorMapObject *)NULL);
+      }
 
     Object->ColorCount = ColorCount;
     Object->BitsPerPixel = BitSize(ColorCount);