[前][次][番号順一覧][スレッド一覧]

ruby-changes:37938

From: nobu <ko1@a...>
Date: Thu, 19 Mar 2015 10:31:12 +0900 (JST)
Subject: [ruby-changes:37938] nobu:r50019 (trunk): random.c: fix handle to release

nobu	2015-03-19 10:31:03 +0900 (Thu, 19 Mar 2015)

  New Revision: 50019

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50019

  Log:
    random.c: fix handle to release
    
    * random.c (fill_random_bytes): release the handle in the static
      variable, not a local variable.

  Modified files:
    trunk/ChangeLog
    trunk/random.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50018)
+++ ChangeLog	(revision 50019)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Mar 19 10:31:00 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@a...>
 
 	* object.c (rb_obj_clone): do not touch age (FL_PROMOTED[01]) because
Index: random.c
===================================================================
--- random.c	(revision 50018)
+++ random.c	(revision 50019)
@@ -485,13 +485,13 @@ fill_random_bytes(void *seed, size_t siz https://github.com/ruby/ruby/blob/trunk/random.c#L485
 	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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]