jding-xyz commented on code in PR #152:
URL: https://github.com/apache/arrow-swift/pull/152#discussion_r3007329434


##########
Sources/Arrow/ArrowReader.swift:
##########
@@ -195,9 +195,12 @@ public class ArrowReader { // swiftlint:disable:this 
type_body_length
         let arrowNullBuffer = makeBuffer(nullBuffer, fileData: 
loadInfo.fileData,
                                          length: nullLength, messageOffset: 
loadInfo.messageOffset)
         let arrowOffsetBuffer = makeBuffer(offsetBuffer, fileData: 
loadInfo.fileData,
-                                           length: UInt(node.length), 
messageOffset: loadInfo.messageOffset)
+                                           length: UInt(node.length + 1), 
messageOffset: loadInfo.messageOffset)
+        let lastOffset = arrowOffsetBuffer.rawPointer
+            .advanced(by: Int(node.length) * MemoryLayout<Int32>.stride)
+            .load(as: Int32.self)
         let arrowValueBuffer = makeBuffer(valueBuffer, fileData: 
loadInfo.fileData,
-                                          length: UInt(node.length), 
messageOffset: loadInfo.messageOffset)
+                                          length: UInt(lastOffset), 
messageOffset: loadInfo.messageOffset)

Review Comment:
   Added guards to reject negative offsets and offsets exceeding the value 
buffer length, returning .failure(.invalid(...)) with a descriptive message. 
This is consistent with the existing guard chain in the method.



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