diff --git a/src/lib/os/os_file.go b/src/lib/os/os_file.go index ee4deef72a7c55b18c60ebd4188507ce8a7e48a0..2667a1e21296c7078c453ee4bd8029fcae72d1c8 100644 --- a/src/lib/os/os_file.go +++ b/src/lib/os/os_file.go @@ -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) }