Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion arrow/array/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ func (d *Data) Release() {
}

for _, b := range d.childData {
b.Release()
if b != nil {
b.Release()
}
}

if d.dictionary != nil {
Expand Down
19 changes: 19 additions & 0 deletions arrow/array/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,22 @@ func TestSizeInBytes(t *testing.T) {
}
})
}

func TestDataReleaseWithNilChildData(t *testing.T) {
mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
defer mem.AssertSize(t, 0)

// Create a Data object that simulates the state after a failed concatenation
// where childData slice is allocated but contains nil elements
buffers := []*memory.Buffer{memory.NewBufferBytes([]byte("test-buffer"))}
data := NewData(arrow.ListOf(arrow.PrimitiveTypes.Int32), 1, buffers, nil, 0, 0)

// Simulate the scenario where childData is allocated but elements remain nil
// This happens in concat.go when childData is allocated but concat() fails
data.childData = make([]arrow.ArrayData, 1)
// data.childData[0] remains nil (simulating failed concat)

assert.NotPanics(t, func() {
data.Release()
}, "Release() should not panic when childData contains nil elements")
}
Loading