fallintoplace commented on code in PR #1132:
URL: https://github.com/apache/arrow-go/pull/1132#discussion_r3752643967


##########
arrow/memory/buffer_test.go:
##########
@@ -58,6 +58,17 @@ func TestNewResizableBuffer(t *testing.T) {
        assert.Zero(t, buf.Len())
 }
 
+func TestCheckedAllocatorReallocate(t *testing.T) {
+       mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
+       defer mem.AssertSize(t, 0)
+
+       buf := mem.Reallocate(16, nil)
+       assert.Len(t, buf, 16)
+
+       buf = mem.Reallocate(0, buf)
+       assert.Empty(t, buf)

Review Comment:
   Okay, so I checked the allocator implementations and Buffer path. The 
allocator contract consistently treats len(b) as the owned allocation size, and 
Buffer keeps its logical length separately while passing the full allocation 
slice to Reallocate. So a len-zero, positive-capacity slice cannot reach this 
through Buffer.
   
   A direct caller could manufacture one, but that already disagrees with the 
accounting and free behavior across the allocator implementations. I switched 
the guard to len(b) > 0 so the pointer handling matches that contract, used 
unsafe.SliceData, and hoisted the deletion.



-- 
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]

Reply via email to