summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--random.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f5732f6..2f5c1d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Mar 19 10:31:00 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * random.c (fill_random_bytes): release the handle in the static
+ variable, not a local variable.
+
Thu Mar 19 06:30:35 2015 Koichi Sasada <ko1@atdot.net>
* object.c (rb_obj_clone): do not touch age (FL_PROMOTED[01]) because
diff --git a/random.c b/random.c
index fed85e0..dc90af4 100644
--- a/random.c
+++ b/random.c
@@ -485,13 +485,13 @@ fill_random_bytes(void *seed, size_t size)
if (!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
prov = (HCRYPTPROV)INVALID_HANDLE_VALUE;
}
- old_prov = (HCRYPTPROV)ATOMIC_SIZE_CAS(perm_prov, 0, prov);
+ old_prov = (HCRYPTPROV)ATOMIC_PTR_CAS(perm_prov, 0, prov);
if (prov == (HCRYPTPROV)INVALID_HANDLE_VALUE) {
if (old_prov) prov = old_prov;
}
else {
if (!old_prov) {
- rb_gc_register_mark_object(Data_Wrap_Struct(0, 0, release_crypt, &prov));
+ rb_gc_register_mark_object(Data_Wrap_Struct(0, 0, release_crypt, &perm_prov));
}
else {
CryptReleaseContext(prov, 0);