From 160b2e156e1c2c1e7d8db6b5e3f6ccf75e9dd34f Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 12 Jan 2015 12:10:45 -0800 Subject: [PATCH] ssh/agent: do not return nil entries from keyring.Signers() The slice returned is constructed with both a pre-set length and append() resulting in a slice twice as long and half-full of nil. Setting the capacity instead of length gets the desired result. Change-Id: I758423594e4f4c0506c53f227454f57a9dc8bdf1 Reviewed-on: https://go-review.googlesource.com/2659 Reviewed-by: Brad Fitzpatrick --- ssh/agent/keyring.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssh/agent/keyring.go b/ssh/agent/keyring.go index 831a5b9..8ac2009 100644 --- a/ssh/agent/keyring.go +++ b/ssh/agent/keyring.go @@ -175,7 +175,7 @@ func (r *keyring) Signers() ([]ssh.Signer, error) { return nil, errLocked } - s := make([]ssh.Signer, len(r.keys)) + s := make([]ssh.Signer, 0, len(r.keys)) for _, k := range r.keys { s = append(s, k.signer) }