GPU: guard zero/overflowing stride in expand_rects and add primitive.rs unit tests #1061

Closed
opened 2026-11-26 04:18:42 +00:00 by github-bot · 0 comments
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 15:24 UTC · original

Summary

Guards expand_rects in crates/victory-gpu/src/primitive.rs against zero or overflowing stride (which previously panicked in chunks_exact(0) or 6 * stride arithmetic) and adds 3 deterministic synthetic unit tests (7 total in primitive.rs).

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@test/gpu-primitive-audit
  • Commit: geiyiliyabumo/VIctory@e3c9dd0 (based on main ffe310e)

Changes (crates/victory-gpu/src/primitive.rs)

  • Bug fix: expand_rects now returns early when stride == 0 or stride.checked_mul(3) / stride.checked_mul(6) overflows.
  • Tests (+3 synthetic, 7 total):
    • zero_or_overflowing_stride_is_ignored_without_panicking
    • unorm16_unorm8_clamping_and_unknown_formats_expand_correctly
    • multiple_rectangles_and_f32_f16_vector_formats_expand_in_sequence

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check crates/victory-gpu/src/primitive.rs: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-gpu --locked -- primitive::: 7 passed, 0 failed

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 15:24 UTC · [original](https://github.com/Marvisak/VIctory/issues/1061) ### Summary Guards `expand_rects` in `crates/victory-gpu/src/primitive.rs` against zero or overflowing `stride` (which previously panicked in `chunks_exact(0)` or `6 * stride` arithmetic) and adds 3 deterministic synthetic unit tests (7 total in `primitive.rs`). Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@test/gpu-primitive-audit` - **Commit**: `geiyiliyabumo/VIctory@e3c9dd0` (based on `main` `ffe310e`) ### Changes (`crates/victory-gpu/src/primitive.rs`) - **Bug fix**: `expand_rects` now returns early when `stride == 0` or `stride.checked_mul(3)` / `stride.checked_mul(6)` overflows. - **Tests (+3 synthetic, 7 total)**: - `zero_or_overflowing_stride_is_ignored_without_panicking` - `unorm16_unorm8_clamping_and_unknown_formats_expand_correctly` - `multiple_rectangles_and_f32_f16_vector_formats_expand_in_sequence` ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check crates/victory-gpu/src/primitive.rs`: **PASS** - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-gpu --locked -- primitive::`: **7 passed, 0 failed** *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:18:42 +00:00
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#1061
No description provided.