trxcllnt commented on code in PR #320:
URL: https://github.com/apache/arrow-js/pull/320#discussion_r2492835720


##########
src/builder/buffer.ts:
##########
@@ -27,8 +27,10 @@ function roundLengthUpToNearest64Bytes(len: number, BPE: 
number) {
 
 /** @ignore */
 function resizeArray<T extends TypedArray | BigIntArray>(arr: T, len = 0): T {
+    // Use slice() to create a copy instead of subarray() which creates a view
+    // This prevents issues where the underlying buffer might be reused/cleared
     return arr.length >= len ?
-        arr.subarray(0, len) as T :
+        arr.slice(0, len) as T :

Review Comment:
   The `subarray()` here was intentional, this is a very costly change. If this 
needs to be a copy for one of the new types, the new code should intentionally 
copy outside this function.



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