Mesa (mesa_7_6_branch): progs/samples: Fix memory leak if fopen fails in rgbtoppm.c.

Vinson Lee vlee at kemper.freedesktop.org
Sat Dec 5 01:40:15 PST 2009


Module: Mesa
Branch: mesa_7_6_branch
Commit: 412aeeed1c392ab5796c85287fc6ebdccd74880c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=412aeeed1c392ab5796c85287fc6ebdccd74880c

Author: Vinson Lee <vlee at vmware.com>
Date:   Sat Dec  5 01:38:14 2009 -0800

progs/samples: Fix memory leak if fopen fails in rgbtoppm.c.

---

 progs/samples/rgbtoppm.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/progs/samples/rgbtoppm.c b/progs/samples/rgbtoppm.c
index 116d9a8..6652bb3 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);



More information about the mesa-commit mailing list