Skip to content

Commit

Permalink
ssh/agent: do not return nil entries from keyring.Signers()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marineam authored and bradfitz committed Jan 12, 2015
1 parent 632d287 commit 160b2e1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ssh/agent/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 160b2e1

Please sign in to comment.