Avoid double close in delete_dir_contents.
fdopendir takes ownership of the file descriptor, leading to it being
closed by both unique_fd's destructor and closedir.
Test: treehugger
Change-Id: Ibd193e988c77c5323720531445f334c0795c68b9
diff --git a/Utils.cpp b/Utils.cpp
index 8af616d..f7afde5 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -818,7 +818,8 @@
result = -errno;
continue;
}
- std::unique_ptr<DIR, decltype(&closedir)> subdirp(fdopendir(subfd), closedir);
+ std::unique_ptr<DIR, decltype(&closedir)> subdirp(
+ android::base::Fdopendir(std::move(subfd)), closedir);
if (!subdirp) {
PLOG(ERROR) << "Couldn't fdopendir " << name;
result = -errno;