Return early on empty range in inplace::views_gone #351

Merged
ahmetbagci8 merged 1 commit from upstream-pr/351 into main 2026-11-27 19:24:45 +00:00
ahmetbagci8 commented 2026-11-27 19:11:01 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by ahmetbagci8 on 2026-11-27T19:11:01Z.


Summary

In crates/victory-gpu/src/inplace.rs, views_gone(at, 0) computed end = at.saturating_add(0) = at and called v.views.range(at.saturating_add(1)..end) when v.views was non-empty, which panics in BTreeMap::range (range start is greater than range end). Even without the panic, first would match and remove any view covering at despite [at, at + 0) being empty.

Changes

  • Return early when len == 0 at the start of views_gone.
  • Add unit test views_gone_empty_range_leaves_existing_views_alone.

Tested

  • cargo test -p victory-gpu --lib inplace: 9 passed; 0 failed; 0 ignored
  • cargo clippy -p victory-gpu --tests: clean (0 warnings)
<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5531855702 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/351). Originally posted by [ahmetbagci8](https://github.com/ahmetbagci8) on 2026-11-27T19:11:01Z. --- ### Summary In `crates/victory-gpu/src/inplace.rs`, `views_gone(at, 0)` computed `end = at.saturating_add(0) = at` and called `v.views.range(at.saturating_add(1)..end)` when `v.views` was non-empty, which panics in `BTreeMap::range` (`range start is greater than range end`). Even without the panic, `first` would match and remove any view covering `at` despite `[at, at + 0)` being empty. ### Changes - Return early when `len == 0` at the start of `views_gone`. - Add unit test `views_gone_empty_range_leaves_existing_views_alone`. ### Tested - `cargo test -p victory-gpu --lib inplace`: `9 passed; 0 failed; 0 ignored` - `cargo clippy -p victory-gpu --tests`: clean (0 warnings)
TaynanGT commented 2026-11-27 19:27:53 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T19:27:53Z.


@ahmetbagci8 Merged as 1d83085. The regression test keeps the mapped view for an empty range and still removes it for a non-empty range. Both CI test suites and Clippy passed.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7226552685 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/351#issuecomment-7226552685). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T19:27:53Z. --- @ahmetbagci8 Merged as `1d83085`. The regression test keeps the mapped view for an empty range and still removes it for a non-empty range. Both CI test suites and Clippy passed.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
TaynanGT/Vice-Tay!351
No description provided.