diff src/dgif_lib.c @ 3462:6c7605dfcf07

[xemacs-hg @ 2006-06-19 18:19:33 by james] Fix various problems found by static checkers: use of uninitialized values, dereferencing pointers before checking whether they are NULL, memory leaks, and incomplete checking of return values. <m3k67gpyhk.fsf@jerrypc.cs.usu.edu>
author james
date Mon, 19 Jun 2006 18:19:38 +0000
parents 00f374c78661
children
line wrap: on
line diff
--- a/src/dgif_lib.c	Mon Jun 19 18:10:19 2006 +0000
+++ b/src/dgif_lib.c	Mon Jun 19 18:19:38 2006 +0000
@@ -366,10 +366,11 @@
 ******************************************************************************/
 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: */
@@ -929,8 +930,10 @@
 	return((ColorMapObject *)NULL);
 
     Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
-    if (Object->Colors == (GifColorType *)NULL)
+    if (Object->Colors == (GifColorType *)NULL) {
+	free(Object);
 	return((ColorMapObject *)NULL);
+    }
 
     Object->ColorCount = ColorCount;
     Object->BitsPerPixel = BitSize(ColorCount);