Quellcode durchsuchen

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 <bradfitz@golang.org>
Michael Marineau vor 11 Jahren
Ursprung
Commit
160b2e156e
1 geänderte Dateien mit 1 neuen und 1 gelöschten Zeilen
  1. 1 1
      ssh/agent/keyring.go

+ 1 - 1
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)
 	}