******************************************************************************/
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: */
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:
Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
if (Object->Colors == (GifColorType *)NULL)
+ {
+ free (Object);
return((ColorMapObject *)NULL);
+ }
Object->ColorCount = ColorCount;
Object->BitsPerPixel = BitSize(ColorCount);