From 2e3dc2cc352fbf006af492f2d5a75d28194e7202 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 13 Jul 2010 12:37:47 -0700 Subject: [PATCH] crypto/rand: add missing Unlock R=r CC=golang-dev https://golang.org/cl/1812043 --- src/pkg/crypto/rand/rand_unix.go | 1 + src/pkg/crypto/rand/rand_windows.go | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pkg/crypto/rand/rand_unix.go b/src/pkg/crypto/rand/rand_unix.go index d8db6f2a041..ff16f25547f 100644 --- a/src/pkg/crypto/rand/rand_unix.go +++ b/src/pkg/crypto/rand/rand_unix.go @@ -32,6 +32,7 @@ func (r *devReader) Read(b []byte) (n int, err os.Error) { if r.f == nil { f, err := os.Open(r.name, os.O_RDONLY, 0) if f == nil { + r.mu.Unlock() return 0, err } r.f = f diff --git a/src/pkg/crypto/rand/rand_windows.go b/src/pkg/crypto/rand/rand_windows.go index 9bab2cba888..4b2b7a26f37 100755 --- a/src/pkg/crypto/rand/rand_windows.go +++ b/src/pkg/crypto/rand/rand_windows.go @@ -30,6 +30,7 @@ func (r *rngReader) Read(b []byte) (n int, err os.Error) { const flags = syscall.CRYPT_VERIFYCONTEXT | syscall.CRYPT_SILENT ok, errno := syscall.CryptAcquireContext(&r.prov, nil, nil, provType, flags) if !ok { + r.mu.Unlock() return 0, os.NewSyscallError("CryptAcquireContext", errno) } }