]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/rand: add missing Unlock
authorRuss Cox <rsc@golang.org>
Tue, 13 Jul 2010 19:37:47 +0000 (12:37 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 13 Jul 2010 19:37:47 +0000 (12:37 -0700)
R=r
CC=golang-dev
https://golang.org/cl/1812043

src/pkg/crypto/rand/rand_unix.go
src/pkg/crypto/rand/rand_windows.go

index d8db6f2a041b6be9fc592ee38b61126e7f35fe05..ff16f25547fa81993269220ebab23ac05610d68d 100644 (file)
@@ -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
index 9bab2cba888a17b6c1f0772f3ba0dcc52a9ad8fa..4b2b7a26f37f214fe7f3b34636fc78641c7fbe33 100755 (executable)
@@ -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)
                }
        }