Skip to content

Commit e8afecc

Browse files
authored
Miscellaneous fixes (KhronosGroup#558)
* Check for correct model when loading BASIS_LZ file. Fixes KhronosGroup#557. * Fix mismatched visibility warning in ktx2check. * Ensure failed status is noticed after reuse lint. * Fix license omissions in previous PR.
1 parent 43a5492 commit e8afecc

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

lib/basis_transcode.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ ktxTexture2_transcodeUastc(ktxTexture2* This,
138138
uint32_t* BDB = This->pDfd + 1;
139139
khr_df_model_e colorModel = (khr_df_model_e)KHR_DFDVAL(BDB, MODEL);
140140
if (colorModel != KHR_DF_MODEL_UASTC
141+
// Constructor has checked color model matches BASIS_LZ.
141142
&& This->supercompressionScheme != KTX_SS_BASIS_LZ)
142-
return KTX_INVALID_OPERATION; // Not in a transcodable format.
143+
{
144+
return KTX_INVALID_OPERATION; // Not in a transcodable format.
145+
}
143146

144147
DECLARE_PRIVATE(priv, This);
145148
if (This->supercompressionScheme == KTX_SS_BASIS_LZ) {
@@ -174,7 +177,6 @@ ktxTexture2_transcodeUastc(ktxTexture2* This,
174177
}
175178
}
176179
} else {
177-
assert(colorModel == KHR_DF_MODEL_UASTC);
178180
uint32_t channelId = KHR_DFDSVAL(BDB, 0, CHANNELID);
179181
if (channelId == KHR_DF_CHANNEL_UASTC_RGBA)
180182
alphaContent = eAlpha;

lib/texture2.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,13 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream,
709709
}
710710
This->isCompressed = (This->_protected->_formatSize.flags & KTX_FORMAT_SIZE_COMPRESSED_BIT);
711711

712+
if (This->supercompressionScheme == KTX_SS_BASIS_LZ
713+
&& KHR_DFDVAL(This->pDfd + 1, MODEL) != KHR_DF_MODEL_ETC1S)
714+
{
715+
result = KTX_FILE_DATA_ERROR;
716+
goto cleanup;
717+
}
718+
712719
This->_private->_requiredLevelAlignment
713720
= ktxTexture2_calcRequiredLevelAlignment(This);
714721

0 commit comments

Comments
 (0)