Copilot commented on code in PR #1291:
URL: https://github.com/apache/arrow-java/pull/1291#discussion_r3985661522
##########
vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthViewVector.java:
##########
@@ -1526,19 +1518,43 @@ public int hashCode(int index, ArrowBufHasher hasher) {
if (isNull(index)) {
return ArrowBufPointer.NULL_HASH_CODE;
}
- final int length = getValueLength(index);
- if (length < INLINE_SIZE) {
- int start = index * ELEMENT_SIZE + LENGTH_WIDTH;
- return ByteFunctionHelpers.hash(hasher, this.getDataBuffer(), start,
start + length);
- } else {
- final int bufIndex =
+ return getData(
+ index,
+ (buf, offset, length) -> ByteFunctionHelpers.hash(hasher, buf, offset,
offset + length));
+ }
+
+ @FunctionalInterface
+ protected interface ViewElementConsumer<T> {
+ T consume(ArrowBuf buf, int offset, int length);
+ }
+
+ /** Helper to get a single view value with sanity checking. */
+ protected <T> T getData(int index, ViewElementConsumer<T> consumer) {
Review Comment:
The new checked access path does not cover
`splitAndTransferViewBufferAndDataBuffer`. Its out-of-line branch still calls
`target.allocateOrGetLastDataBuffer(stringLength)` before validating the source
offset/length, so a crafted IPC view can still trigger the large allocation
this change is intended to prevent via `splitAndTransferTo`. Route that branch
through `getData` (or apply the same validation) before allocating the target
buffer.
--
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]