[PATCH 04/10] shared: Don't leak file descriptor in shared/image-loader.c

Martin Olsson martin at minimum.se
Sat Jul 7 18:03:41 PDT 2012


---
 shared/image-loader.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/shared/image-loader.c b/shared/image-loader.c
index a3218df..b47c1a7 100644
--- a/shared/image-loader.c
+++ b/shared/image-loader.c
@@ -359,8 +359,10 @@ load_image(const char *filename)
 	if (fp == NULL)
 		return NULL;
 
-	if (fread(header, sizeof header, 1, fp) != 1)
+	if (fread(header, sizeof header, 1, fp) != 1) {
+		fclose(fp);
 		return NULL;
+	}
 
 	rewind(fp);
 	for (i = 0; i < ARRAY_LENGTH(loaders); i++) {
-- 
1.7.9.5



More information about the wayland-devel mailing list