diff options
author | Mikhail Mazurskiy <mmazurskiy@gitlab.com> | 2022-08-24 15:32:33 +0300 |
---|---|---|
committer | Mikhail Mazurskiy <mmazurskiy@gitlab.com> | 2022-08-26 14:10:38 +0300 |
commit | b7b64d3ec5ff19f50d432a07cd6ac6c05ab141f5 (patch) | |
tree | 83fd01875fb30ad1bab1198fa1c9d91dda5a4714 | |
parent | 2f05fe7dc3ae746ebbc539ecf02be79f5e0965ef (diff) |
Do not mutate the original options slice
-rw-r--r-- | internal/gitaly/client/dial.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/gitaly/client/dial.go b/internal/gitaly/client/dial.go index 4b76b3756..84800995d 100644 --- a/internal/gitaly/client/dial.go +++ b/internal/gitaly/client/dial.go @@ -57,6 +57,8 @@ type Handshaker interface { // If handshaker is provided, it's passed the transport credentials which would be otherwise set. The transport credentials // returned by handshaker are then set instead. func Dial(ctx context.Context, rawAddress string, connOpts []grpc.DialOption, handshaker Handshaker) (*grpc.ClientConn, error) { + connOpts = cloneOpts(connOpts) // copy to avoid potentially mutating the backing array of the passed slice + var canonicalAddress string var err error var transportCredentials credentials.TransportCredentials @@ -149,3 +151,9 @@ func UnaryInterceptor() grpc.DialOption { grpccorrelation.UnaryClientCorrelationInterceptor(), ) } + +func cloneOpts(opts []grpc.DialOption) []grpc.DialOption { + clone := make([]grpc.DialOption, len(opts)) + copy(clone, opts) + return clone +} |