From 417ec07b594353a5a851a2de315a4bb26c91d2c1 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Fri, 6 Jan 2023 00:10:34 +0100 Subject: [PATCH] dialer: move negotiated extension and copy extension parameters Fixes following issue: Extensions in Handshake returned from (Dialer) Upgrade contain slices pointing to memory in buffer already returned to pbufio.ReaderPool. --- dialer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dialer.go b/dialer.go index d8b81a4..64d4681 100644 --- a/dialer.go +++ b/dialer.go @@ -485,8 +485,10 @@ func matchSelectedExtensions(selected []byte, wanted, received []httphead.Option if bytes.Equal(option.Name, want.Name) { // Check parsed extension to be present in client // requested extensions. We move matched extension - // from client list to avoid allocation. - received = append(received, option) + // from client list to avoid allocation of httphead.Option.Name, + // httphead.Option.Parameters have to be copied from the header + want.Parameters, _ = option.Parameters.Copy(make([]byte, option.Parameters.Size())) + received = append(received, want) return true } }