Revision: 16889
Author: [email protected]
Date: Mon Sep 23 14:11:32 2013 UTC
Log: Let SetEntropySource() fail if called after V8::Initialize().
BUG=v8:2905
[email protected]
Review URL: https://codereview.chromium.org/24357002
http://code.google.com/p/v8/source/detail?r=16889
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Mon Sep 23 11:27:07 2013 UTC
+++ /branches/bleeding_edge/include/v8.h Mon Sep 23 14:11:32 2013 UTC
@@ -4540,6 +4540,9 @@
/**
* 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);
=======================================
--- /branches/bleeding_edge/src/api.cc Mon Sep 23 11:25:52 2013 UTC
+++ /branches/bleeding_edge/src/api.cc Mon Sep 23 14:11:32 2013 UTC
@@ -5175,6 +5175,13 @@
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);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.