From 9e3a61ab902ada0db81ddf81ad14d7cf9e3c2df7 Mon Sep 17 00:00:00 2001 From: Matheus Degiovani Date: Fri, 30 Aug 2024 15:06:38 -0300 Subject: [PATCH] codec: Fix demux returning data to pool after Unmarshal The passed slice cannot be guaranteed to be from the pool, therefore it should not be returned there during Release. --- codec.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codec.go b/codec.go index c68ec375..0ff86440 100644 --- a/codec.go +++ b/codec.go @@ -162,6 +162,11 @@ func Unmarshal(data []byte) (*Message, error) { } arena := MultiSegment(nil) + + // We cannot return the data parameter to the bufferpool because we + // don't know where it came from. + arena.bp = nil + if err := arena.demux(hdr, data); err != nil { return nil, exc.WrapError("unmarshal", err) }