From 686cecf24216770190133aa6f270bb2b124329a7 Mon Sep 17 00:00:00 2001 From: "fork0@users.sf.net" Date: Tue, 8 Jun 2004 16:47:16 -0700 Subject: [PATCH] [PATCH] fix handle leak in udev_lib.c There is a handle leak in failure path in file_map, and the result of file_map (or the result of the caller of the file_map) is not always checked. --- udev_lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/udev_lib.c b/udev_lib.c index 16b473f5..8f6aa423 100644 --- a/udev_lib.c +++ b/udev_lib.c @@ -124,11 +124,13 @@ int file_map(const char *filename, char **buf, size_t *bufsize) } if (fstat(fd, &stats) < 0) { + close(fd); return -1; } *buf = mmap(NULL, stats.st_size, PROT_READ, MAP_SHARED, fd, 0); if (*buf == MAP_FAILED) { + close(fd); return -1; } *bufsize = stats.st_size; -- 2.39.5