DirectStorage: clear the factory out pointer on failure #1718

Open
davutsimsekk wants to merge 1 commit from upstream-pr/1719 into main
davutsimsekk commented 2026-11-24 21:15:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by davutsimsekk on 2026-11-24T21:15:03Z.


DStorageGetFactory is declared _COM_Outptr_ void** ppv: on failure *ppv must be null. When the requested IID was not the factory's (or riid was null) the HLE returned E_NOINTERFACE without touching *ppv, leaving a stale caller pointer that a title's probe would dereference.

This nulls *ppv before matching the IID, returns E_INVALIDARG for a null out pointer, and leaves the success path unchanged.

Reference: the public dstorage.h declaration of DStorageGetFactory(REFIID riid, _COM_Outptr_ void** ppv).

Test

a_refused_factory_interface_clears_the_out_pointer checks an unknown IID and a null IID both return E_NOINTERFACE with a null out pointer, and a null out pointer returns E_INVALIDARG.

  • cargo test -p victory-hle --lib: 95 passed, 0 failed
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean
  • The changed hunks are rustfmt-clean; the file has unrelated pre-existing formatting.
  • The title was not run.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6591558249 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1719). Originally posted by [davutsimsekk](https://github.com/davutsimsekk) on 2026-11-24T21:15:03Z. --- `DStorageGetFactory` is declared `_COM_Outptr_ void** ppv`: on failure `*ppv` must be null. When the requested IID was not the factory's (or `riid` was null) the HLE returned `E_NOINTERFACE` without touching `*ppv`, leaving a stale caller pointer that a title's probe would dereference. This nulls `*ppv` before matching the IID, returns `E_INVALIDARG` for a null out pointer, and leaves the success path unchanged. Reference: the public `dstorage.h` declaration of `DStorageGetFactory(REFIID riid, _COM_Outptr_ void** ppv)`. ## Test `a_refused_factory_interface_clears_the_out_pointer` checks an unknown IID and a null IID both return `E_NOINTERFACE` with a null out pointer, and a null out pointer returns `E_INVALIDARG`. - `cargo test -p victory-hle --lib`: 95 passed, 0 failed - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: clean - The changed hunks are rustfmt-clean; the file has unrelated pre-existing formatting. - The title was not run.
DenRakEiw commented 2026-11-24 21:28:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T21:26:27Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-hle --lib dstorage:: — 14 passed, 0 failed (including a_refused_factory_interface_clears_the_out_pointer)
  • cargo clippy -p victory-hle --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean COM out-pointer clearing on DStorageGetFactory failure with unit test coverage. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6047683156 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1719#pullrequestreview-6047683156). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T21:26:27Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-hle --lib dstorage::` — 14 passed, 0 failed (including `a_refused_factory_interface_clears_the_out_pointer`) - `cargo clippy -p victory-hle --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean COM out-pointer clearing on `DStorageGetFactory` failure with unit test coverage. Looks good. AI-assisted (Gemini 4 Neon).
mercuryVM commented 2026-11-24 22:02:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T21:56:03Z.

Review: APPROVED


Tested 7714674 on Windows 11, RTX 5070, MSVC: builds, cargo test --workspace --no-fail-fast 640 passed, 0 failed (on our fork main), clippy -D warnings clean with and without --all-features. a_refused_factory_interface_clears_the_out_pointer passes.

  • _COM_Outptr_ requires *ppv to be null on failure, and nulling it before the IID match does that for both the unknown-IID and null-IID paths. The success arm then writes the factory, unchanged.
  • E_INVALIDARG for a null ppv is what the COM convention expects (some implementations return E_POINTER, but either is a failure the title checks the same way).

Merged into our fork's main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6048040078 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1719#pullrequestreview-6048040078). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T21:56:03Z. **Review:** APPROVED --- Tested 7714674 on Windows 11, RTX 5070, MSVC: builds, `cargo test --workspace --no-fail-fast` 640 passed, 0 failed (on our fork main), clippy `-D warnings` clean with and without `--all-features`. `a_refused_factory_interface_clears_the_out_pointer` passes. - `_COM_Outptr_` requires `*ppv` to be null on failure, and nulling it before the IID match does that for both the unknown-IID and null-IID paths. The success arm then writes the factory, unchanged. - `E_INVALIDARG` for a null `ppv` is what the COM convention expects (some implementations return `E_POINTER`, but either is a failure the title checks the same way). Merged into our fork's main. AI-assisted (Claude Code).
catminou4 commented 2026-11-24 23:05:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T22:20:07Z.

Review: COMMENTED


Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.

DirectStorage factory out pointer cleared on failure (dstorage.rs, 1.8K) — avoids a dangling pointer on the error path. Small correctness fix.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048314086 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1719#pullrequestreview-6048314086). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T22:20:07Z. **Review:** COMMENTED --- Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff. DirectStorage factory out pointer cleared on failure (dstorage.rs, 1.8K) — avoids a dangling pointer on the error path. Small correctness fix.
kais7654 commented 2026-11-24 23:05:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-24T22:38:49Z.


Reviewed and verified: COM_Outptr semantics hold now — the out
pointer is cleared on entry, a null out gets E_INVALIDARG, and the
caller's stale value is gone after E_NOINTERFACE. Test passes on
Windows.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146478245 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1719#issuecomment-7146478245). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-24T22:38:49Z. --- Reviewed and verified: _COM_Outptr_ semantics hold now — the out pointer is cleared on entry, a null out gets E_INVALIDARG, and the caller's stale value is gone after E_NOINTERFACE. Test passes on Windows.
Marvisak commented 2026-11-25 04:06:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:35:47Z.


Automated triage for the maintainers.

Merge candidate. DStorageGetFactory in crates/victory-hle/src/modules/dstorage.rs now returns E_INVALIDARG for a null out pointer, and sets *out to null before checking the IID, so an E_NOINTERFACE result no longer leaves the caller's stale pointer. This follows the out-pointer convention, and the success path (through put) is unchanged. The new test covers an unknown IID, a null IID and a null out pointer. CI has not run.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152061328 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1719#issuecomment-7152061328). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T03:35:47Z. --- <!-- victory-triage v1 head=771467458b5d26b6ff8c35dd8b4747a0f7f37537 verdict=merge-candidate at=2026-11-25T03:41:20Z --> Automated triage for the maintainers. **Merge candidate.** `DStorageGetFactory` in `crates/victory-hle/src/modules/dstorage.rs` now returns `E_INVALIDARG` for a null out pointer, and sets `*out` to null before checking the IID, so an `E_NOINTERFACE` result no longer leaves the caller's stale pointer. This follows the out-pointer convention, and the success path (through `put`) is unchanged. The new test covers an unknown IID, a null IID and a null out pointer. CI has not run. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 01:04:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:01:25Z.


Code review and Windows 11 verification at head 771467458b5d merged cleanly onto main (63bcca43c6a0):

  • Code review (crates/victory-hle/src/modules/dstorage.rs:52-68):
    • DStorageGetFactory checks out.is_null() first (E_INVALIDARG), immediately clears *out = null_mut(), and then validates iid (E_NOINTERFACE for null/unknown GUIDs with *out guaranteed null, S_OK via put for FACTORY). New test a_refused_factory_interface_clears_the_out_pointer covers unknown IID, null IID, and null out.
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy -p victory-hle --all-targets -- -D warnings: 0 warnings
    • victory-hle --lib -- dstorage:: --test-threads=1: 17/17 passed.

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179348476 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1719#issuecomment-7179348476). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T01:01:25Z. --- Code review and Windows 11 verification at head `771467458b5d` merged cleanly onto `main` (`63bcca43c6a0`): - **Code review (`crates/victory-hle/src/modules/dstorage.rs:52-68`)**: - `DStorageGetFactory` checks `out.is_null()` first (`E_INVALIDARG`), immediately clears `*out = null_mut()`, and then validates `iid` (`E_NOINTERFACE` for null/unknown GUIDs with `*out` guaranteed null, `S_OK` via `put` for `FACTORY`). New test `a_refused_factory_interface_clears_the_out_pointer` covers unknown IID, null IID, and null `out`. - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy -p victory-hle --all-targets -- -D warnings`: 0 warnings - `victory-hle --lib -- dstorage:: --test-threads=1`: **17/17 passed**. LGTM.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1719:upstream-pr/1719'
git switch 'upstream-pr/1719'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1719'
git switch 'upstream-pr/1719'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1719'
git switch 'upstream-pr/1719'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1719'
git switch 'main'
git merge --squash 'upstream-pr/1719'
git switch 'main'
git merge --ff-only 'upstream-pr/1719'
git switch 'main'
git merge 'upstream-pr/1719'
git push origin 'main'
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!1718
No description provided.