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

Open
opened 2026-11-26 11:57:16 +00:00 by kekonn · 0 comments
kekonn commented 2026-11-26 11:57:16 +00:00 (Migrated from github.com)
Contributor

Imported from avatarmanz/VIctory-7900XTX. Originally posted by kekonn on 2026-11-26T11:57:16Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6626138755 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/issues/218). Originally posted by [kekonn](https://github.com/kekonn) on 2026-11-26T11:57:16Z. --- `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)_
Sign in to join this conversation.
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
avatarmanz/VIctory-7900XTX#218
No description provided.