From 30bf19f2833c4a73bab97a06a6cb0b2b81fe9896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 30 Aug 2023 21:26:30 +0800 Subject: [PATCH] Check nil buffer in CopyPacketWithSrcBuffer --- common/bufio/copy.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/bufio/copy.go b/common/bufio/copy.go index b5cb412..926211e 100644 --- a/common/bufio/copy.go +++ b/common/bufio/copy.go @@ -5,6 +5,7 @@ import ( "errors" "io" "net" + "reflect" "syscall" "github.com/sagernet/sing/common" @@ -292,6 +293,9 @@ func CopyPacketWithSrcBuffer(originSource N.PacketReader, destinationConn N.Pack if err != nil { return } + if buffer == nil { + panic("nil buffer returned from " + reflect.TypeOf(source).String()) + } dataLen := buffer.Len() if dataLen == 0 { continue