Commit c5751ce7 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Let SetEntropySource() fail if called after V8::Initialize().

BUG=v8:2905
R=dslomov@chromium.org

Review URL: https://codereview.chromium.org/24357002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16889 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4af9fa96
......@@ -4540,6 +4540,9 @@ class V8_EXPORT V8 {
/**
* Allows the host application to provide a callback which can be used
* as a source of entropy for random number generators.
*
* \note Setting an entropy source can only be done very early prior to
* calling Initialize().
*/
static void SetEntropySource(EntropySource source);
......
......@@ -5175,6 +5175,13 @@ bool v8::V8::Initialize() {
void v8::V8::SetEntropySource(EntropySource entropy_source) {
// The entropy source must be set before the library is initialized,
// as otherwise not all random number generators will pick up the
// entropy source and will fall back to weak entropy instead.
i::Isolate* isolate = i::Isolate::UncheckedCurrent();
ApiCheck(isolate != NULL && isolate->IsInitialized(),
"v8::V8::SetEntropySource",
"Cannot set entropy source once V8 is initialized.");
i::RandomNumberGenerator::SetEntropySource(entropy_source);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment