mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 08:31:28 +00:00
Check buffer before releasing
to avoid `extending out of bound` issue in some cases
This commit is contained in:
parent
1e3d739a5b
commit
b977899926
|
@ -27,7 +27,7 @@ type Buffer struct {
|
||||||
// New creates a Buffer with 0 length and 2K capacity.
|
// New creates a Buffer with 0 length and 2K capacity.
|
||||||
func New() *Buffer {
|
func New() *Buffer {
|
||||||
return &Buffer{
|
return &Buffer{
|
||||||
v: pool.Get().([]byte),
|
v: buf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,10 @@ func (b *Buffer) Release() {
|
||||||
p := b.v
|
p := b.v
|
||||||
b.v = nil
|
b.v = nil
|
||||||
b.Clear()
|
b.Clear()
|
||||||
pool.Put(p)
|
|
||||||
|
if cap(p) >= Size {
|
||||||
|
pool.Put(p)
|
||||||
|
}
|
||||||
b.UDP = nil
|
b.UDP = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue