Skip to content

Commit f477726

Browse files
committed
Minor fixes
1 parent 8122af0 commit f477726

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

common/buf/alloc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (alloc *defaultAllocator) Get(size int) []byte {
8989
// which the cap must be exactly 2^n
9090
func (alloc *defaultAllocator) Put(buf []byte) error {
9191
bits := msb(cap(buf))
92-
if cap(buf) == 0 || cap(buf) < 64 || cap(buf) > 65536 || cap(buf) != 1<<bits {
92+
if cap(buf) < 64 || cap(buf) > 65536 || cap(buf) != 1<<bits {
9393
return errors.New("allocator Put() incorrect buffer size")
9494
}
9595
bits -= 6

common/udpnat2/conn.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"sync"
99
"time"
1010

11+
"github.com/sagernet/sing/common"
1112
"github.com/sagernet/sing/common/buf"
1213
"github.com/sagernet/sing/common/canceler"
1314
M "github.com/sagernet/sing/common/metadata"
@@ -108,6 +109,7 @@ func (c *natConn) SetTimeout(timeout time.Duration) bool {
108109
func (c *natConn) Close() error {
109110
c.closeOnce.Do(func() {
110111
close(c.doneChan)
112+
common.Close(c.handler)
111113
})
112114
return nil
113115
}

0 commit comments

Comments
 (0)