fix panic when writing empty objects

fixes #58
This commit is contained in:
Joshua C. Randall 2018-06-29 14:48:43 +00:00
parent bd5bc6d4cb
commit 3c08133264

View File

@ -99,8 +99,13 @@ func (ioctx *IOContext) Write(oid string, data []byte, offset uint64) error {
c_oid := C.CString(oid)
defer C.free(unsafe.Pointer(c_oid))
dataPointer := unsafe.Pointer(nil)
if len(data) > 0 {
dataPointer = unsafe.Pointer(&data[0])
}
ret := C.rados_write(ioctx.ioctx, c_oid,
(*C.char)(unsafe.Pointer(&data[0])),
(*C.char)(dataPointer),
(C.size_t)(len(data)),
(C.uint64_t)(offset))