summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-19 01:31:03 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-19 01:31:03 (GMT)
commit5e132260c4de9f221d480b526264e131d93ac69d (patch)
tree3c41daf3c5ddf855a6ca77af42e770e2735cb692 /random.c
parent56081d8a606720219102758a33166e1bbfeec1a1 (diff)
random.c: fix handle to release
* random.c (fill_random_bytes): release the handle in the static variable, not a local variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c4
1 files changed, 2 insertions, 2 deletions
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);