Skip to content

Commit 57988b9

Browse files
committed
Restore errno after closing failed FD
Ref: #440 `close(fd)` resets `errno`, so when we return with a failure, the original error cause is lost.
1 parent 7639d0d commit 57988b9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ext/bootsnap/bootsnap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,9 @@ open_current_file(char * path, struct bs_cache_key * key, const char ** errno_pr
377377

378378
if (fstat(fd, &statbuf) < 0) {
379379
*errno_provenance = "bs_fetch:open_current_file:fstat";
380+
int previous_errno = errno;
380381
close(fd);
382+
errno = previous_errno;
381383
return -1;
382384
}
383385

0 commit comments

Comments
 (0)