From 412aeeed1c392ab5796c85287fc6ebdccd74880c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 5 Dec 2009 01:38:14 -0800 Subject: progs/samples: Fix memory leak if fopen fails in rgbtoppm.c. --- progs/samples/rgbtoppm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/progs/samples/rgbtoppm.c b/progs/samples/rgbtoppm.c index 116d9a8cfa5b..6652bb32ec1e 100644 --- a/progs/samples/rgbtoppm.c +++ b/progs/samples/rgbtoppm.c @@ -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); -- cgit v1.2.3