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

Side by Side Diff: runtime/bin/dartutils.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 | « no previous file | runtime/bin/file.h » ('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 "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "bin/crypto.h" 7 #include "bin/crypto.h"
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 #include "bin/extensions.h" 9 #include "bin/extensions.h"
10 #include "bin/file.h" 10 #include "bin/file.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 intptr_t num_bytes, 215 intptr_t num_bytes,
216 void* stream) { 216 void* stream) {
217 ASSERT(stream != NULL); 217 ASSERT(stream != NULL);
218 File* file_stream = reinterpret_cast<File*>(stream); 218 File* file_stream = reinterpret_cast<File*>(stream);
219 bool bytes_written = file_stream->WriteFully(buffer, num_bytes); 219 bool bytes_written = file_stream->WriteFully(buffer, num_bytes);
220 ASSERT(bytes_written); 220 ASSERT(bytes_written);
221 } 221 }
222 222
223 223
224 void DartUtils::CloseFile(void* stream) { 224 void DartUtils::CloseFile(void* stream) {
225 delete reinterpret_cast<File*>(stream); 225 File* file = reinterpret_cast<File*>(stream);
226 file->Release();
226 } 227 }
227 228
228 229
229 bool DartUtils::EntropySource(uint8_t* buffer, intptr_t length) { 230 bool DartUtils::EntropySource(uint8_t* buffer, intptr_t length) {
230 return Crypto::GetRandomBytes(length, buffer); 231 return Crypto::GetRandomBytes(length, buffer);
231 } 232 }
232 233
233 234
234 static Dart_Handle SingleArgDart_Invoke(Dart_Handle lib, const char* method, 235 static Dart_Handle SingleArgDart_Invoke(Dart_Handle lib, const char* method,
235 Dart_Handle arg) { 236 Dart_Handle arg) {
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 new CObjectString(CObject::NewString(os_error->message())); 1256 new CObjectString(CObject::NewString(os_error->message()));
1256 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1257 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1257 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1258 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1258 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1259 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1259 result->SetAt(2, error_message); 1260 result->SetAt(2, error_message);
1260 return result; 1261 return result;
1261 } 1262 }
1262 1263
1263 } // namespace bin 1264 } // namespace bin
1264 } // namespace dart 1265 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698