[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.
This commit is contained in:
fork0@users.sf.net 2004-06-08 16:47:16 -07:00 committed by Greg KH
parent e3496f5932
commit 686cecf242

View file

@ -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;