From f71ea8c456d30aee004e4e368ab8c89c74a2a5a2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 17 Jun 2016 21:51:16 -0400 Subject: Correctly handle 0-length byte arrays in IO. --- proto/io.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/proto/io.go b/proto/io.go index 3c0c5be..1f46503 100644 --- a/proto/io.go +++ b/proto/io.go @@ -48,9 +48,11 @@ func Write(fd io.Writer, data interface{}) { case nslcdObject: data.nslcdWrite(fd) case []byte: - _, err := fd.Write(data) - if err != nil { - panic(err) + if len(data) > 0 { + _, err := fd.Write(data) + if err != nil { + panic(err) + } } case int32: err := binary.Write(fd, binary.BigEndian, data) @@ -109,9 +111,11 @@ func Read(fd io.Reader, data interface{}) { case nslcdObjectPtr: data.nslcdRead(fd) case *[]byte: - _, err := fd.Read(*data) - if err != nil { - panic(err) + if len(*data) > 0 { + _, err := fd.Read(*data) + if err != nil { + panic(err) + } } case *int32: err := binary.Read(fd, binary.BigEndian, data) -- cgit v1.2.3-2-g168b