mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-03 21:23:48 +00:00
[PR #2031] Fix use-after-free bugs in Rust userdata handling #2837
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/2031
State: closed
Merged: Yes
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Description
While reviewing userdata.rs, I found another instance of the same use-after-free pattern in the Unrecognized user data handling.
The current code creates a temporary Vec using .to_vec() and immediately extracts a raw pointer from it using .as_mut_ptr().
Because the temporary Vec is dropped right after .as_mut_ptr(), the pointer passed to dump() becomes dangling, resulting in use-after-free undefined behavior.
This is the same issue that was fixed earlier in this file.
Fix
Store the Vec in a local variable so its lifetime extends until after the dump() call:
This guarantees the backing memory remains valid for the duration of the call.