Index: runtime/bin/directory_macos.cc |
diff --git a/runtime/bin/directory_macos.cc b/runtime/bin/directory_macos.cc |
index 074647fed70cdc525bc1250827dad9bb0516a0f0..feb9a9ca8dec1a7045eaac9bef0a6badd322c3e2 100644 |
--- a/runtime/bin/directory_macos.cc |
+++ b/runtime/bin/directory_macos.cc |
@@ -187,14 +187,18 @@ ListType DirectoryListingEntry::Next(DirectoryListing* listing) { |
return kListError; |
} |
- if (closedir(reinterpret_cast<DIR*>(lister_)) == -1) { |
- return kListError; |
- } |
- |
return kListDone; |
} |
+DirectoryListingEntry::~DirectoryListingEntry() { |
+ ResetLink(); |
+ if (lister_ != 0) { |
+ closedir(reinterpret_cast<DIR*>(lister_)); |
+ } |
+} |
+ |
+ |
void DirectoryListingEntry::ResetLink() { |
if (link_ != NULL && (parent_ == NULL || parent_->link_ != link_)) { |
delete link_; |