HLE: reject null output pointers in DirectStorage factory and release FidelityFX DLL on load failure #2580

Closed
github-bot wants to merge 1 commit from github-bot/gh-2580 into main AGit
Owner

@⁠reeledMarek on GitHub · 2026-11-25 16:09 UTC · original
reeledMarek:fix/hle-null-out-and-dll-leaks → main · +58 −0 · 2 files · 1 commits · closed without merging

Summary

Fixes two resource leaks on error paths in victory-hle:

  1. dstorage.rs (create_status_array, create_queue): validates out.is_null() upfront and returns E_INVALIDARG before heap-allocating Instance<StatusArray> / Instance<Queue> or permanently inserting a Lane into scheduler().
  2. fidelityfx.rs (load): guards the HMODULE returned by LoadLibraryExW with an RAII Drop wrapper (FreeLibrary), disarming it only when Ok((host, versions)) succeeds, so failed export lookups, missing host GPU, or failed versions() queries do not leak the loaded DLL handle.

Testing

  • Added synthetic unit test null_out_is_rejected_before_creating_status_array_or_queue in dstorage.rs.
  • cargo test -p xtask --locked (6/6 passed).
  • Full Windows build, clippy, and test suite verified via GitHub Actions CI.
**@⁠reeledMarek** on GitHub · 2026-11-25 16:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/2580) `reeledMarek:fix/hle-null-out-and-dll-leaks` → `main` · +58 −0 · 2 files · 1 commits · closed without merging ### Summary Fixes two resource leaks on error paths in `victory-hle`: 1. **`dstorage.rs` (`create_status_array`, `create_queue`):** validates `out.is_null()` upfront and returns `E_INVALIDARG` before heap-allocating `Instance<StatusArray>` / `Instance<Queue>` or permanently inserting a `Lane` into `scheduler()`. 2. **`fidelityfx.rs` (`load`):** guards the `HMODULE` returned by `LoadLibraryExW` with an RAII `Drop` wrapper (`FreeLibrary`), disarming it only when `Ok((host, versions))` succeeds, so failed export lookups, missing host GPU, or failed `versions()` queries do not leak the loaded DLL handle. ### Testing - Added synthetic unit test `null_out_is_rejected_before_creating_status_array_or_queue` in `dstorage.rs`. - `cargo test -p xtask --locked` (6/6 passed). - Full Windows build, clippy, and test suite verified via GitHub Actions CI.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:43 +00:00
github-bot closed this pull request 2026-11-26 06:30:42 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:18 UTC · original

Automated triage for the maintainers.

Proposed close: no practical value. Both changes cover cases that do not happen or cost nothing:

  • dstorage.rs: create_status_array and create_queue already return E_INVALIDARG for a null out, through xgameruntime::put. The new early checks only avoid one small allocation (and one idle lane) for a call that passes no out pointer, which the title does not do. The test checks the error code, which main already returns.
  • fidelityfx.rs: load runs once and only on the user's own FidelityFX DLL. On failure, keeping the module loaded costs nothing. Freeing it after versions() has already called ffxQuery on the host device is less safe than leaving it loaded, because the DLL may hold state tied to that device.

CI (check) passes and it merges cleanly. This PR will be closed in 48 hours unless the author pushes a change (for example a real path where the title passes a null out) or a maintainer removes the triage: proposed close label.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2580#issuecomment-7176203822) <!-- victory-triage v1 head=687e82b69a3b6bd2dc7ecff29c5c1a79acf917af verdict=proposed-close at=2026-11-25T22:18:35Z --> Automated triage for the maintainers. **Proposed close: no practical value.** Both changes cover cases that do not happen or cost nothing: - `dstorage.rs`: `create_status_array` and `create_queue` already return `E_INVALIDARG` for a null `out`, through `xgameruntime::put`. The new early checks only avoid one small allocation (and one idle lane) for a call that passes no out pointer, which the title does not do. The test checks the error code, which `main` already returns. - `fidelityfx.rs`: `load` runs once and only on the user's own FidelityFX DLL. On failure, keeping the module loaded costs nothing. Freeing it after `versions()` has already called `ffxQuery` on the host device is less safe than leaving it loaded, because the DLL may hold state tied to that device. CI (`check`) passes and it merges cleanly. This PR will be closed in 48 hours unless the author pushes a change (for example a real path where the title passes a null out) or a maintainer removes the `triage: proposed close` label. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠reeledMarek on GitHub · 2026-11-26 05:43 UTC · original

Closing per triage: xgameruntime::put already returns E_INVALIDARG on a null out pointer, and unloading the FidelityFX DLL after ffxQuery is less safe than keeping it loaded. Thanks for the review!

**@⁠reeledMarek** on GitHub · 2026-11-26 05:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2580#issuecomment-7183748971) Closing per triage: `xgameruntime::put` already returns `E_INVALIDARG` on a null out pointer, and unloading the FidelityFX DLL after `ffxQuery` is less safe than keeping it loaded. Thanks for the review!

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!2580
No description provided.