mirror of https://github.com/v2ray/v2ray-core
Recycle memory earlier in error case
parent
8334d5177e
commit
fe7d2d8984
|
@ -11,6 +11,9 @@ const (
|
||||||
func ReadFrom(reader io.Reader) ([]byte, error) {
|
func ReadFrom(reader io.Reader) ([]byte, error) {
|
||||||
buffer := make([]byte, bufferSize)
|
buffer := make([]byte, bufferSize)
|
||||||
nBytes, err := reader.Read(buffer)
|
nBytes, err := reader.Read(buffer)
|
||||||
|
if nBytes == 0 {
|
||||||
|
buffer = nil
|
||||||
|
}
|
||||||
return buffer[:nBytes], err
|
return buffer[:nBytes], err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue