Fix crash when assigning invalid model TXD IDs#5041
Open
HeresHavi wants to merge 1 commit into
Open
Conversation
Reject unavailable TXD pool slots before changing a model's texture dictionary. This prevents invalid IDs from reaching GTA's unchecked TXD lookup and causing a client crash during later texture operations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Added TXD slot validation to
engineSetModelTXDIDand made the pool availability check bounds safe.Invalid or unallocated TXD IDs are now rejected before the model or its reference counts are changed.
Motivation
engineSetModelTXDIDchecked the model ID but accepted any unsigned 16-bit TXD ID. This allowed an unavailable slot to remain stored on a loaded model. A later operation such asengineGetModelTextureNamescould pass that ID into GTA's unchecked TXD lookup and crash the client.For example, a resource might cache a TXD ID so it can update a player model later. If that slot was released during a resource restart, reusing the stale ID could leave the model pointing at missing TXD data. The next texture query could then crash the player.
Valid IDs returned by
engineRequestTXDare still accepted.Crash Stack
Test plan
Runtime
65535was accepted for a loaded model, and querying its texture names caused an access violation in GTA's TXD lookup.engineRequestTXDwere both accepted.Builds and Tests
Debug | Win32: Solution build passed, 304 client tests passed.Release | Win32: Solution build passed, 304 client tests passed.clang-format.Checklist