From 561f31245df2447c683635e62bb08c4074698b53 Mon Sep 17 00:00:00 2001 From: "Xiaokang Wang (Shelikhoo)" Date: Thu, 27 Feb 2025 14:32:04 +0000 Subject: [PATCH] A temporary testing fix for the buffer corruption issue (#3331) --- app/dispatcher/default.go | 5 ++++- common/protocol/quic/sniff.go | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 64a0d252286..4365a272870 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -250,7 +250,10 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, network net.Network) (SniffResult, error) { payload := buf.New() - defer payload.Release() + + defer func() { + payload.Release() + }() sniffer := NewSniffer(ctx) diff --git a/common/protocol/quic/sniff.go b/common/protocol/quic/sniff.go index 77eef605a88..3d9af98f501 100644 --- a/common/protocol/quic/sniff.go +++ b/common/protocol/quic/sniff.go @@ -52,7 +52,9 @@ func SniffQUIC(b []byte) (*SniffHeader, error) { // Crypto data separated across packets cryptoLen := 0 cryptoData := bytespool.Alloc(int32(len(b))) - defer bytespool.Free(cryptoData) + defer func() { + bytespool.Free(cryptoData) + }() cache := buf.New() defer cache.Release()