hle: return S_OK with null handle when PowerSetRequest returns ERROR_NOT_SUPPORTED #1664

Closed
github-bot wants to merge 1 commit from gh-pr/1664/head into gh-pr/1664/base
Owner

@⁠Satanyuga on GitHub · 2026-11-24 20:34 UTC · original
Satanyuga:fix/display-deferral-not-supported → main · +64 −7 · 1 files · 1 commits · closed without merging

Fixes issue #727: program crashed on Windows ERROR_NOT_SUPPORTED (0x32) from PowerSetRequest in acquire_deferral.

Changes:

  • Extracted pure helper map_power_set_request_error(hr, out):
    • When hr == NOT_SUPPORTED (0x8007_0032), writes null to out via put() and returns S_OK.
    • Other errors returned unchanged; out untouched (COM rules).
  • handle_power_set_request_failure closes the request handle and delegates to the helper, passing the out pointer — eliminates UB from uninitialized out on S_OK return.
  • acquire_deferral calls the new helper on PowerSetRequest failure.

Tests added (all passing):

  • error_not_supported_returns_ok_with_null_handle — calls map_power_set_request_error(NOT_SUPPORTED, &mut out) and asserts hr == S_OK + out.is_null(), plus verifies E_FAIL leaves out untouched (sentinel preserved).
  • close_deferral_safely_ignores_null_handle — verifies close_deferral no-ops on null handle.

Verified:

  • cargo test -p victory-hle — 96 tests pass
  • cargo clippy -p victory-hle --all-targets -- -D warnings — 0 warnings, 0 errors
**@⁠Satanyuga** on GitHub · 2026-11-24 20:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1664) `Satanyuga:fix/display-deferral-not-supported` → `main` · +64 −7 · 1 files · 1 commits · closed without merging Fixes issue #727: program crashed on Windows `ERROR_NOT_SUPPORTED` (0x32) from `PowerSetRequest` in `acquire_deferral`. **Changes:** - Extracted pure helper `map_power_set_request_error(hr, out)`: - When `hr == NOT_SUPPORTED` (0x8007_0032), writes `null` to `out` via `put()` and returns `S_OK`. - Other errors returned unchanged; `out` untouched (COM rules). - `handle_power_set_request_failure` closes the request handle and delegates to the helper, passing the `out` pointer — eliminates UB from uninitialized `out` on `S_OK` return. - `acquire_deferral` calls the new helper on `PowerSetRequest` failure. **Tests added (all passing):** - `error_not_supported_returns_ok_with_null_handle` — calls `map_power_set_request_error(NOT_SUPPORTED, &mut out)` and asserts `hr == S_OK` + `out.is_null()`, plus verifies `E_FAIL` leaves `out` untouched (sentinel preserved). - `close_deferral_safely_ignores_null_handle` — verifies `close_deferral` no-ops on null handle. **Verified:** - `cargo test -p victory-hle` — 96 tests pass - `cargo clippy -p victory-hle --all-targets -- -D warnings` — 0 warnings, 0 errors
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:40:40 +00:00
github-bot closed this pull request 2026-11-26 04:40:40 +00:00
Author
Owner

@⁠acetonahard-code on GitHub · 2026-11-24 22:10 UTC · original

Heads-up: #1155 (opened about four hours earlier) also says it fixes #727, the PowerSetRequest ERROR_NOT_SUPPORTED failure in acquire_deferral. The two conflict in display.rs, so only one can land as-is.

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 101 0 0
  • The 2 new tests pass.
  • 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.

**@⁠acetonahard-code** on GitHub · 2026-11-24 22:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/1664#issuecomment-7145902659) Heads-up: #1155 (opened about four hours earlier) also says it fixes #727, the `PowerSetRequest` `ERROR_NOT_SUPPORTED` failure in `acquire_deferral`. The two conflict in `display.rs`, so only one can land as-is. 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 | 101 | 0 | 0 | - The 2 new tests pass. - `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>
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:23 UTC · original

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #1155. Same fix for #727 as #1155, but it hands the title S_OK with a null handle; #1155's non-null no-op handle is the safer form of the same idea.

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.

**@⁠Marvisak** on GitHub · 2026-11-25 01:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1664#issuecomment-7149502930) Automated triage for the maintainers. Closing because another open pull request covers the same change. See #1155. Same fix for #727 as #1155, but it hands the title S_OK with a null handle; #1155's non-null no-op handle is the safer form of the same idea. 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!1664
No description provided.