mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Make file_id_for_fd return kInvalidFiledID when passed a negative fd
Rather than making fstat do this, make it explicit.
This commit is contained in:
parent
6eb1e31070
commit
83f386347f
1 changed files with 1 additions and 1 deletions
|
@ -683,7 +683,7 @@ file_id_t file_id_t::file_id_from_stat(const struct stat *buf) {
|
|||
file_id_t file_id_for_fd(int fd) {
|
||||
file_id_t result = kInvalidFileID;
|
||||
struct stat buf = {};
|
||||
if (0 == fstat(fd, &buf)) {
|
||||
if (fd >= 0 && 0 == fstat(fd, &buf)) {
|
||||
result = file_id_t::file_id_from_stat(&buf);
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue