From: fork0@users.sf.net Date: Tue, 8 Jun 2004 23:47:16 +0000 (-0700) Subject: [PATCH] fix handle leak in udev_lib.c X-Git-Tag: 027~3 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=686cecf24216770190133aa6f270bb2b124329a7;p=systemd [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. --- 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;