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

   ### Rationale for this change
   
   `KeyValueMetadata::DeleteMany` crashes (out-of-bounds write) when the 
indices vector
   contains duplicates, e.g. `DeleteMany({0, 0})`. The compaction loop 
increments its `shift`
   counter once per entry, so duplicates cause writes at negative offsets.
   
   Additionally, out-of-range indices were only checked by `DCHECK`, so in 
release builds
   `DeleteMany({size})` silently deleted the last element and negative indices 
were UB.
   
   ### What changes are included in this PR?
   
   - `DeleteMany` now validates indices after sorting and returns 
`Status::IndexError` for
     any index out of `[0, size)`, matching the behavior and message format of 
`Delete`.
     Metadata is left unmodified on error.
   - Duplicate indices are removed with `std::unique` before compaction, so 
deleting the
     same index twice is equivalent to deleting it once.
   
   ### Are these changes tested?
   
   Yes — added cases to `KeyValueMetadataTest.Delete` covering duplicate indices
   (`{0,0}`, `{1,3,1,3,1}`), out-of-bounds positive and negative indices (exact 
error
   messages), and that metadata is unchanged after a failed call.
   
   ### Are there any user-facing changes?
   
   Yes, minor behavioral fix: `DeleteMany` now returns `IndexError` for 
out-of-range indices
   instead of crashing (duplicates) or silently corrupting state (release 
builds). No API change.
   


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