Close descriptor in ScopeFd destructor
The underlying descriptor is supposed to be closed when the ScopedFd
goes out of scope but due to a typo in reset() that never happens.
This change was inspired by an earlier implementation of ScopedFd in:
04dc91ae7 Load library using file handle.
Issue: 143918215
Test: Manual (verify fd usage on device)
Change-Id: I5664fa82d3e732113732e34a7ae6df3ca79d3cee
diff --git a/libc/private/ScopedFd.h b/libc/private/ScopedFd.h
index 9b1cd9d..1cec916 100644
--- a/libc/private/ScopedFd.h
+++ b/libc/private/ScopedFd.h
@@ -46,7 +46,7 @@
}
void reset(int fd = -1) {
- if (fd != -1) {
+ if (fd_ != -1) {
ErrnoRestorer e;
close(fd_);
}