Commit 23c8faaf authored by Robert Griesemer's avatar Robert Griesemer

buf fix: make FD.Read, FD.Write work for empty buffers

R=r
DELTA=8  (6 added, 0 deleted, 2 changed)
OCL=19273
CL=19275
parent f3e354ec
......@@ -57,7 +57,10 @@ func (fd *FD) Read(b *[]byte) (ret int, err *Error) {
if fd == nil {
return -1, EINVAL
}
r, e := syscall.read(fd.fd, &b[0], int64(len(b)));
var r, e int64;
if len(b) > 0 { // because we access b[0]
r, e = syscall.read(fd.fd, &b[0], int64(len(b)));
}
return int(r), ErrnoToError(e)
}
......@@ -65,7 +68,10 @@ func (fd *FD) Write(b *[]byte) (ret int, err *Error) {
if fd == nil {
return -1, EINVAL
}
r, e := syscall.write(fd.fd, &b[0], int64(len(b)));
var r, e int64;
if len(b) > 0 { // because we access b[0]
r, e = syscall.write(fd.fd, &b[0], int64(len(b)));
}
return int(r), ErrnoToError(e)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment