Skip to content

Commit

Permalink
codec: Fix demux returning data to pool after Unmarshal
Browse files Browse the repository at this point in the history
The passed slice cannot be guaranteed to be from the pool, therefore it
should not be returned there during Release.
  • Loading branch information
matheusd committed Aug 30, 2024
1 parent 153d699 commit 9e3a61a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 9e3a61a

Please sign in to comment.