Fix null dereference when building a texture from memory - #112
Open
hard25670559 wants to merge 1 commit into
Open
Fix null dereference when building a texture from memory#112hard25670559 wants to merge 1 commit into
hard25670559 wants to merge 1 commit into
Conversation
The image constructor assigned the mip set to its parameter rather than to the member that PerformUpload reads, so `img` was still null by the time Upload dereferenced it. Any call to this constructor crashed. Assign to the member instead.
This was referenced Aug 10, 2026
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.
Problem
r_tex_c(r_ITexManager*, std::unique_ptr<image_c>, int)assigns the mip set to its parameter rather than to the memberPerformUploadreads:PerformUploadthen doestex->Upload(*tex->img, tex->flags)on a nullimg, so every use of this constructor crashes. There appear to be no in-tree callers, which is presumably why it has gone unnoticed.Change
Assign to the member.
Verification
Found while building textures from memory in a downstream branch: the constructor crashed with
EXC_BAD_ACCESSatr_tex_c::Uploadon the first call, and worked after this one-line change. Existing texture loading paths go throughLoadFile/Uploaddirectly and are untouched.