You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/01/18 20:19:20 UTC

[GitHub] [arrow] jorisvandenbossche commented on a change in pull request #12182: ARROW-15360: [Python] Check slice bounds in Buffer.slice()

jorisvandenbossche commented on a change in pull request #12182:
URL: https://github.com/apache/arrow/pull/12182#discussion_r787118442



##########
File path: python/pyarrow/io.pxi
##########
@@ -1056,10 +1056,10 @@ cdef class Buffer(_Weakrefable):
             raise IndexError('Offset must be non-negative')
 
         if length is None:
-            result = SliceBuffer(self.buffer, offset)
+            result = GetResultValue(SliceBufferSafe(self.buffer, offset))
         else:
-            result = SliceBuffer(self.buffer, offset, max(length, 0))
-
+            result = GetResultValue(SliceBufferSafe(self.buffer, offset,
+                                                    max(length, 0)))

Review comment:
       Side question: should we rather raise an error for negative lengths? This `max(length, 0)` basically turns a negative length into an empty slice?




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org