HyukjinKwon opened a new pull request, #49111:
URL: https://github.com/apache/arrow/pull/49111

   ### Rationale for this change
   
   Previously, `DataType::field(int i)` directly accessed `children_[i]` 
without bounds checking, resulting in undefined behavior for out-of-bounds 
indices. This could crash or return garbage.
   
   ### What changes are included in this PR?
   
   Added bounds checking to `DataType::field()` to return `nullptr` for 
out-of-bounds access, matching the behavior of `GetFieldByName()`.
   
   ### Are these changes tested?
   
   Yes, added `TestStructType.FieldAccessOutOfBounds` to verify that 
out-of-bounds indices return `nullptr`.
   
   ### Are there any user-facing changes?
   
   Yes. `DataType::field(i)` now safely returns `nullptr` for invalid indices 
instead of undefined behavior.


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