1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-02 15:36:41 -05:00

Recycle memory earlier in error case

This commit is contained in:
V2Ray 2015-10-06 17:24:16 +02:00
parent 8334d5177e
commit fe7d2d8984

View File

@ -11,6 +11,9 @@ const (
func ReadFrom(reader io.Reader) ([]byte, error) {
buffer := make([]byte, bufferSize)
nBytes, err := reader.Read(buffer)
if nBytes == 0 {
buffer = nil
}
return buffer[:nBytes], err
}