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
gugelfrei
Josh Gao 6 years ago
parent 298fa3264f
commit e3c32e0d2f

@ -818,7 +818,8 @@ static status_t delete_dir_contents(DIR* dir) {
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;

Loading…
Cancel
Save