HLE: guard against null GWLP_USERDATA in XGameUi dialog WM_COMMAND handler #1373
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1373"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-24T17:39:12Z.
In
crates/victory-hle/src/modules/xgameui.rs,dialog::procedurepreviously formed&mut *(wm::GetWindowLongPtrW(dialog, wm::GWLP_USERDATA) as *mut Entry)unconditionally in theWM_COMMANDhandler. IfWM_COMMANDarrives beforeWM_INITDIALOGinitializesGWLP_USERDATA, forming&mut Entryfrom null is immediate UB and crashes onIDOK.Changes
(wm::GetWindowLongPtrW(dialog, wm::GWLP_USERDATA) as *mut Entry).as_mut()indialog::procedureand return0when user data is null.dialog::procedurepub(super)for direct unit testing and addeddialog_wm_command_ignores_missing_user_data.Verification
cargo test -p victory-hle --target x86_64-pc-windows-msvc --locked xgameui::(2 passed; 0 failed)cargo clippy --workspace --all-targets --target x86_64-pc-windows-msvc --locked -- -D warningsRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --target x86_64-pc-windows-msvc --lockedcargo run -p xtask --target x86_64-pc-windows-msvc --locked -- policy --staged(asset policy: 1 files ok)Imported from Marvisak/VIctory. Originally posted by BaggyALPHA on 2026-11-24T17:41:17Z.
Review: COMMENTED
I reproduced this independently on Windows using a real hidden Win32 window whose user data was still zero. Calling the dialog procedure with an OK command aborted on a null dereference on upstream main. With this PR applied, the same hidden-window test returned unhandled for OK, Cancel and an edit-control command. The HLE suite passed 97 tests including that temporary probe. No visible dialog or game files were needed.
AI-assisted (Codex).
Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T21:03:55Z.
Tested on Windows 11 with the repo toolchain, merged into current
main(ffe310e):cargo test -p victory-hlemainmain+ this PRcargo 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.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:38:57Z.
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #1515. Same null user-data guard as #1515, wrapped in reformatting of unrelated lines and a visibility change.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed