zeroshade commented on code in PR #14877:
URL: https://github.com/apache/arrow/pull/14877#discussion_r1043712324
##########
go/arrow/cdata/cdata_exports.go:
##########
@@ -353,7 +366,7 @@ func exportArray(arr arrow.Array, out *CArrowArray,
outSchema *CArrowSchema) {
buffers := allocateBufferPtrArr(len(arr.Data().Buffers()))
for i := range arr.Data().Buffers() {
buf := arr.Data().Buffers()[i]
- if buf == nil {
+ if buf == nil || buf.Len() == 0 {
Review Comment:
The reason for this is line 374 below. In the case where `buf.Len() == 0`
there is no allocated data to grab a pointer to via `&buf.Bytes()[0]` and you
end up panic'ing with an error of attempting to get index 0 of a 0 length
slice. Thus if we create an empty array, it's better to just use a nil pointer.
The alternative here would be to use `&buf.Buf()[0]` instead, which points
at the reserved bytes (since creating a new buffer will, by default,
automatically reserve 64 bytes if it wasn't expanded) but I thought it better
to not force us to keep that memory around for a 0 length array.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]