Allocate the replacement DFD before mutating the texture in the UASTC HDR 4x4 relabel path - #1236
Merged
MarkCallow merged 1 commit intoAug 6, 2026
Conversation
SashaRX
marked this pull request as ready for review
August 5, 2026 14:59
Collaborator
|
Please sign the CLA. |
MarkCallow
reviewed
Aug 6, 2026
SashaRX
force-pushed
the
fix/hdr4x4-relabel-dfd-alloc-order
branch
3 times, most recently
from
August 6, 2026 12:19
b57f0f9 to
9b0f9cb
Compare
The UASTC HDR 4x4 to ASTC HDR 4x4 early exit in ktxTexture2_TranscodeBasis freed the texture's DFD and relabelled vkFormat before calling vk2dfd(). If vk2dfd() returned NULL the function returned an error while leaving the texture with a freed pDfd and an already-changed vkFormat. Allocate the replacement DFD first and only then modify the texture, so failure leaves it untouched. No behavior change on the success path.
SashaRX
force-pushed
the
fix/hdr4x4-relabel-dfd-alloc-order
branch
from
August 6, 2026 12:22
9b0f9cb to
e8354e1
Compare
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.
Small defensive robustness fix in the UASTC_HDR_4x4 → ASTC_HDR_4x4 early exit of
ktxTexture2_TranscodeBasis, related to the passthrough discussion in #1224.Problem
The early exit frees
This->pDfdand updatesThis->vkFormatbefore constructingthe replacement DFD with
vk2dfd().If DFD creation ever reports a failure, the function returns with a partially
mutated texture: the original DFD has already been freed and
vkFormatalreadydescribes ASTC HDR.
Fix
Construct the replacement DFD first. Only after successful construction, free
the old DFD and commit the new
pDfdandvkFormat.There is no behavior change on the success path. The path was smoke-tested with
an encode → relabel-transcode round trip.
No regression test is included because the current generated mapping contains
VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK, and there is no existing failure-injectionmechanism for
vk2dfd(). This is therefore a defensive transactional-orderingfix rather than a currently reproducible input-driven failure.