Skip to content

Commit

Permalink
GH-41534: [Go] Fix mem leak importing 0 length C Array (#41535)
Browse files Browse the repository at this point in the history
### What changes are included in this PR?
If the `imp.alloc.bufCount` is 0, indicating we did not import any buffers from the provided C ArrowArray object, then we are free to not only call the release callback (which we already do) but also we need to free the temp ArrowArray we allocated to move the source to.

This was uncovered by apache/arrow-adbc#1808
* GitHub Issue: #41534

Authored-by: Matt Topol <zotthewizard@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
  • Loading branch information
zeroshade committed May 3, 2024
1 parent e7f5f81 commit 7cd9c6f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions go/arrow/cdata/cdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ func (imp *cimporter) doImportArr(src *CArrowArray) error {
defer func() {
if imp.alloc.bufCount == 0 {
C.ArrowArrayRelease(imp.arr)
C.free(unsafe.Pointer(imp.arr))
}
}()

Expand Down

0 comments on commit 7cd9c6f

Please sign in to comment.