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

Unified Diff: runtime/bin/crypto.cc

Issue 1781883002: Fixes some memory leaks in //runtime/bin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix tests on Windows Created 4 years, 9 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
« no previous file with comments | « runtime/bin/crypto.h ('k') | runtime/bin/crypto_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/crypto.cc
diff --git a/runtime/bin/crypto.cc b/runtime/bin/crypto.cc
index 6becae8be5aca77e084d722f7d01db78ab6e02ec..ec4840fdde94ca06249343653aa68d607a2228c9 100644
--- a/runtime/bin/crypto.cc
+++ b/runtime/bin/crypto.cc
@@ -7,7 +7,6 @@
#include "include/dart_api.h"
-
namespace dart {
namespace bin {
@@ -23,23 +22,20 @@ void FUNCTION_NAME(Crypto_GetRandomBytes)(Dart_NativeArguments args) {
Dart_ThrowException(error);
}
intptr_t count = static_cast<intptr_t>(count64);
- uint8_t* buffer = new uint8_t[count];
+ uint8_t* buffer = Dart_ScopeAllocate(count);
ASSERT(buffer != NULL);
if (!Crypto::GetRandomBytes(count, buffer)) {
- delete[] buffer;
Dart_ThrowException(DartUtils::NewDartOSError());
UNREACHABLE();
}
Dart_Handle result = Dart_NewTypedData(Dart_TypedData_kUint8, count);
if (Dart_IsError(result)) {
- delete[] buffer;
Dart_Handle error = DartUtils::NewString("Failed to allocate storage.");
Dart_ThrowException(error);
UNREACHABLE();
}
Dart_ListSetAsBytes(result, 0, buffer, count);
Dart_SetReturnValue(args, result);
- delete[] buffer;
}
} // namespace bin
« no previous file with comments | « runtime/bin/crypto.h ('k') | runtime/bin/crypto_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698