mirror of https://github.com/grpc/grpc-go.git
metadata: copy slices in FromContext() functions (#5267)
This commit is contained in:
parent
9d088969a8
commit
2fccb822f1
|
|
@ -188,7 +188,9 @@ func FromIncomingContext(ctx context.Context) (MD, bool) {
|
||||||
// map, and there's no guarantee that the MD attached to the context is
|
// map, and there's no guarantee that the MD attached to the context is
|
||||||
// created using our helper functions.
|
// created using our helper functions.
|
||||||
key := strings.ToLower(k)
|
key := strings.ToLower(k)
|
||||||
out[key] = v
|
s := make([]string, len(v))
|
||||||
|
copy(s, v)
|
||||||
|
out[key] = s
|
||||||
}
|
}
|
||||||
return out, true
|
return out, true
|
||||||
}
|
}
|
||||||
|
|
@ -226,7 +228,9 @@ func FromOutgoingContext(ctx context.Context) (MD, bool) {
|
||||||
// map, and there's no guarantee that the MD attached to the context is
|
// map, and there's no guarantee that the MD attached to the context is
|
||||||
// created using our helper functions.
|
// created using our helper functions.
|
||||||
key := strings.ToLower(k)
|
key := strings.ToLower(k)
|
||||||
out[key] = v
|
s := make([]string, len(v))
|
||||||
|
copy(s, v)
|
||||||
|
out[key] = s
|
||||||
}
|
}
|
||||||
for _, added := range raw.added {
|
for _, added := range raw.added {
|
||||||
if len(added)%2 == 1 {
|
if len(added)%2 == 1 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue