progs/samples: Fix memory leak if fopen fails in rgbtoppm.c.
authorVinson Lee <vlee@vmware.com>
Sat, 5 Dec 2009 09:38:14 +0000 (01:38 -0800)
committerVinson Lee <vlee@vmware.com>
Sat, 5 Dec 2009 09:38:14 +0000 (01:38 -0800)
progs/samples/rgbtoppm.c

index 116d9a8cfa5b64eb825a4d4c3e603f4101f7affd..6652bb32ec1e9dfbf9bd7abc819d082c61c99086 100644 (file)
@@ -86,7 +86,8 @@ static ImageRec *ImageOpen(char *fileName)
         exit(1);
     }
     if ((image->file = fopen(fileName, "rb")) == NULL) {
-       return NULL;
+        free(image);
+        return NULL;
     }
 
     fread(image, 1, 12, image->file);