mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-02 16:34:37 +00:00
Merge pull request #4201 from pks-t/pks/fileops-fd-leak
fileops: fix leaking fd in `mmap_ro_file`
This commit is contained in:
commit
f9d3b0d05f
@ -304,15 +304,19 @@ int git_futils_mmap_ro_file(git_map *out, const char *path)
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
if ((len = git_futils_filesize(fd)) < 0)
|
||||
return -1;
|
||||
if ((len = git_futils_filesize(fd)) < 0) {
|
||||
result = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!git__is_sizet(len)) {
|
||||
giterr_set(GITERR_OS, "file `%s` too large to mmap", path);
|
||||
return -1;
|
||||
result = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
result = git_futils_mmap_ro(out, fd, 0, (size_t)len);
|
||||
out:
|
||||
p_close(fd);
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user