xgamesave: InitializeProviderAsync leaks the Provider when XAsyncBegin refuses the block #218

Open
opened 2026-11-26 11:59:04 +00:00 by github-bot · 0 comments
Owner

@⁠kekonn on GitHub · 2026-11-26 11:57 UTC · original

crates/victory-hle/src/modules/xgamesave.rs:669: Provider::open(…).map(|p| xasync::bytes(give(p))), where give is Box::into_raw. This puts a raw owning pointer into the result bytes of xasync::finished_with.

When XAsyncBegin refuses the call, finished_with's refused-begin path (xasync.rs ~828-832) frees only the Box<Result<Vec<u8>, HRESULT>>. A refusal happens for a null block, or a block that still holds an unfetched result. The Provider those bytes point at is never freed. This is the only result payload in the crate that is an owned heap handle.

(A Provider the title never fetches also stays alive, but that follows the XAsync contract and is a one-off small allocation, so it is out of scope.)

Proposed fix (~6 lines)

In initialize_async (~658-672), keep the Result<*mut Provider, HRESULT>. Pass provider.map(xasync::bytes) to finished_with, and if it returns < 0, take(p) the provider.

Upstream: no open PR touches xgamesave.rs or xasync.rs.
Status: a fix is being prepared in kekonn/VIctory-7900XTX on branch claude/gifted-clarke-uxuqw8.


Generated by Claude Code

**@⁠kekonn** on GitHub · 2026-11-26 11:57 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/218) `crates/victory-hle/src/modules/xgamesave.rs:669`: `Provider::open(…).map(|p| xasync::bytes(give(p)))`, where `give` is `Box::into_raw`. This puts a raw owning pointer into the result bytes of `xasync::finished_with`. When `XAsyncBegin` refuses the call, `finished_with`'s refused-begin path (xasync.rs ~828-832) frees only the `Box<Result<Vec<u8>, HRESULT>>`. A refusal happens for a null block, or a block that still holds an unfetched result. The `Provider` those bytes point at is never freed. This is the only result payload in the crate that is an owned heap handle. (A Provider the title never fetches also stays alive, but that follows the XAsync contract and is a one-off small allocation, so it is out of scope.) ### Proposed fix (~6 lines) In `initialize_async` (~658-672), keep the `Result<*mut Provider, HRESULT>`. Pass `provider.map(xasync::bytes)` to `finished_with`, and if it returns < 0, `take(p)` the provider. **Upstream:** no open PR touches `xgamesave.rs` or `xasync.rs`. **Status:** a fix is being prepared in kekonn/VIctory-7900XTX on branch `claude/gifted-clarke-uxuqw8`. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:59:04 +00:00
This discussion has been locked. Commenting is limited to contributors.
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/avatarmanz--VIctory-7900XTX#218
No description provided.