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

Side by Side Diff: runtime/bin/file_win.cc

Issue 1892623002: Fixes leak of native File objects. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/file_unsupported.cc ('k') | runtime/bin/gen_snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <fcntl.h> // NOLINT 10 #include <fcntl.h> // NOLINT
(...skipping 20 matching lines...) Expand all
31 void set_fd(int fd) { fd_ = fd; } 31 void set_fd(int fd) { fd_ = fd; }
32 32
33 private: 33 private:
34 int fd_; 34 int fd_;
35 35
36 DISALLOW_COPY_AND_ASSIGN(FileHandle); 36 DISALLOW_COPY_AND_ASSIGN(FileHandle);
37 }; 37 };
38 38
39 39
40 File::~File() { 40 File::~File() {
41 Close(); 41 if (!IsClosed()) {
42 Close();
43 }
42 delete handle_; 44 delete handle_;
43 } 45 }
44 46
45 47
46 void File::Close() { 48 void File::Close() {
47 ASSERT(handle_->fd() >= 0); 49 ASSERT(handle_->fd() >= 0);
48 if ((handle_->fd() == _fileno(stdout)) || 50 if ((handle_->fd() == _fileno(stdout)) ||
49 (handle_->fd() == _fileno(stderr))) { 51 (handle_->fd() == _fileno(stderr))) {
50 int fd = _open("NUL", _O_WRONLY); 52 int fd = _open("NUL", _O_WRONLY);
51 ASSERT(fd >= 0); 53 ASSERT(fd >= 0);
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 return kIdentical; 687 return kIdentical;
686 } else { 688 } else {
687 return kDifferent; 689 return kDifferent;
688 } 690 }
689 } 691 }
690 692
691 } // namespace bin 693 } // namespace bin
692 } // namespace dart 694 } // namespace dart
693 695
694 #endif // defined(TARGET_OS_WINDOWS) 696 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/file_unsupported.cc ('k') | runtime/bin/gen_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698