Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1511)

Unified Diff: runtime/bin/file_macos.cc

Issue 1892623002: Fixes leak of native File objects. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove unused GetFD Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/bin/file_macos.cc
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc
index 81412f66e0c4440a4898e8bf8076cfae33fe7fcd..c6de3212daf285cf03be64ea0e08f5a85d8bbca7 100644
--- a/runtime/bin/file_macos.cc
+++ b/runtime/bin/file_macos.cc
@@ -40,7 +40,9 @@ class FileHandle {
File::~File() {
- Close();
+ if (!IsClosed()) {
+ Close();
+ }
delete handle_;
}
@@ -199,10 +201,7 @@ File* File::Open(const char* path, FileOpenMode mode) {
File* File::OpenStdio(int fd) {
- if ((fd < 0) || (2 < fd)) {
- return NULL;
- }
- return new File(new FileHandle(fd));
+ return ((fd < 0) || (2 < fd)) ? NULL : new File(new FileHandle(fd));
}

Powered by Google App Engine
This is Rietveld 408576698