HLE: guard dialog commands before initialization #1514

Merged
Calvix2k merged 1 commit from upstream-pr/1515 into main 2026-11-25 00:14:29 +00:00
Calvix2k commented 2026-11-24 18:40:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T18:40:29Z.


Summary

Fixes VIC-BT-033 from audit issue #1242.

The dialog procedure handled WM_COMMAND by immediately turning GWLP_USERDATA into a mutable Entry reference. If a command arrives before WM_INITDIALOG has stored the entry pointer, this dereferences null. The procedure now ignores commands while user data is unset.

A Windows regression test invokes the command handler before initialization and verifies it safely returns without handling the command.

Verification

  • cargo test -p victory-hle --lib --locked — 95 passed
  • cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings — clean
  • cargo xtask policy --staged — passed
  • git diff --check — passed

A file-specific rustfmt --check reports pre-existing formatting differences elsewhere in xgameui.rs; no unrelated formatting changes are included.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588870034 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1515). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T18:40:29Z. --- ## Summary Fixes `VIC-BT-033` from audit issue #1242. The dialog procedure handled `WM_COMMAND` by immediately turning `GWLP_USERDATA` into a mutable `Entry` reference. If a command arrives before `WM_INITDIALOG` has stored the entry pointer, this dereferences null. The procedure now ignores commands while user data is unset. A Windows regression test invokes the command handler before initialization and verifies it safely returns without handling the command. ## Verification - `cargo test -p victory-hle --lib --locked` — 95 passed - `cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings` — clean - `cargo xtask policy --staged` — passed - `git diff --check` — passed A file-specific `rustfmt --check` reports pre-existing formatting differences elsewhere in `xgameui.rs`; no unrelated formatting changes are included.
acetonahard-code commented 2026-11-24 23:05:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T22:30:19Z.


Heads-up: #1373 (opened about an hour earlier) adds the same check. dialog::procedure returns early on a zero GWLP_USERDATA in WM_COMMAND. The two conflict in xgameui.rs.

Tested on Windows 11 with the repo toolchain, merged into current main (70564ae):

cargo test -p victory-hle passed failed ignored
main 99 0 0
main + this PR 100 0 0
  • The new test passes.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146309421 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1515#issuecomment-7146309421). Originally posted by [acetonahard-code](https://github.com/acetonahard-code) on 2026-11-24T22:30:19Z. --- Heads-up: #1373 (opened about an hour earlier) adds the same check. `dialog::procedure` returns early on a zero `GWLP_USERDATA` in `WM_COMMAND`. The two conflict in `xgameui.rs`. Tested on Windows 11 with the repo toolchain, merged into current `main` (70564ae): | `cargo test -p victory-hle` | passed | failed | ignored | |---|---|---|---| | `main` | 99 | 0 | 0 | | `main` + this PR | 100 | 0 | 0 | - The new test passes. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
upstream-sync closed this pull request 2026-11-25 01:06:46 +00:00
Calvix2k commented 2026-11-25 01:08:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T00:41:37Z.


Heads-up acknowledged. #1373 is now closed, so this PR is the surviving fix for the null GWLP_USERDATA case in XGameUi. The xgameui.rs conflict is therefore moot; this one is mergeable and should be the one to take.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148778014 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1515#issuecomment-7148778014). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T00:41:37Z. --- Heads-up acknowledged. #1373 is now closed, so this PR is the surviving fix for the null GWLP_USERDATA case in XGameUi. The xgameui.rs conflict is therefore moot; this one is mergeable and should be the one to take.
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
Marvisak/VIctory!1514
No description provided.