Browse Source

A temporary testing fix for the buffer corruption issue (#3331)

Xiaokang Wang (Shelikhoo) 8 months ago
parent
commit
561f31245d
2 changed files with 7 additions and 2 deletions
  1. 4 1
      app/dispatcher/default.go
  2. 3 1
      common/protocol/quic/sniff.go

+ 4 - 1
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)
 

+ 3 - 1
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()