Skip to content

fix(arrow/scalar): reject negative indices in GetScalar#4

Closed
fornwall wants to merge 1 commit into
mainfrom
fix/scalar-getscalar-negative-index
Closed

fix(arrow/scalar): reject negative indices in GetScalar#4
fornwall wants to merge 1 commit into
mainfrom
fix/scalar-getscalar-negative-index

Conversation

@fornwall

Copy link
Copy Markdown
Owner

Split out from the review of apache#936.

scalar.GetScalar only guarded the upper bound (idx >= arr.Len()), and the IsNull(idx) call ran before that check, so a negative index panicked inside the null-bitmap lookup instead of returning an error. This checks both bounds first and returns arrow.ErrIndex for any out-of-range index.

Complements upstream 950bc29 (apache#927), which validates dictionary scalar indices in Dictionary.ValidateFull/GetEncodedValue; this hardens the underlying GetScalar entry point itself, as suggested in the apache#936 review ("A follow-up hardening scalar.GetScalar/GetEncodedValue to reject negative indices library-wide would be even better").

🤖 Generated with Claude Code

https://claude.ai/code/session_016sey3gTdMfZ9LbLw3BvFJE

GetScalar only guarded the upper bound (idx >= arr.Len()), and the
IsNull(idx) call ran before that check, so a negative index panicked
inside the null-bitmap lookup instead of returning an error.

Check both bounds first and return arrow.ErrIndex for any out-of-range
index.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@fornwall fornwall force-pushed the fix/scalar-getscalar-negative-index branch from d837cb9 to 6bec180 Compare July 14, 2026 21:30
@fornwall fornwall closed this Jul 14, 2026
@fornwall fornwall deleted the fix/scalar-getscalar-negative-index branch July 15, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant