Copilot commented on code in PR #144:
URL: https://github.com/apache/arrow-swift/pull/144#discussion_r2902754054


##########
Sources/Arrow/ArrowBuffer.swift:
##########
@@ -80,9 +80,9 @@ public class ArrowBuffer {
     private static func alignTo64(_ length: UInt) -> UInt {
         let bufAlignment = length % 64
         if bufAlignment != 0 {
-            return length + (64 - bufAlignment) + 8
+            return length + (64 - bufAlignment)
         }
 
-        return length + 8
+        return length

Review Comment:
   This change will alter observed `capacity` values (e.g., 101 bytes now 
aligns to 128 instead of 136). There are existing unit tests asserting 
`capacity == 136` (Tests/ArrowTests/ArrayTests.swift), so CI is likely to fail 
unless those expectations are updated/removed. Also, the PR description claims 
no tests assert on `capacity`, which appears to be incorrect.



##########
Sources/Arrow/ArrowBuffer.swift:
##########
@@ -80,9 +80,9 @@ public class ArrowBuffer {
     private static func alignTo64(_ length: UInt) -> UInt {
         let bufAlignment = length % 64
         if bufAlignment != 0 {
-            return length + (64 - bufAlignment) + 8
+            return length + (64 - bufAlignment)
         }
 
-        return length + 8
+        return length

Review Comment:
   `alignTo64` increases `capacity` beyond the payload length for non-aligned 
buffers, and `append(to:)` writes `capacity` bytes. However, `createBuffer(_ 
data: [UInt8], ...)` allocates uninitialized memory and only copies 
`data.count` bytes, leaving the alignment padding uninitialized; those bytes 
can leak arbitrary memory contents and make IPC output non-deterministic. 
Consider zero-filling the padding region (or initializing the whole allocation) 
whenever `capacity > byteCount`.



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