Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions lib/texture2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2393,13 +2393,17 @@ ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb,
ZSTD_ErrorCode error = ZSTD_getErrorCode(levelSize);
switch(error) {
case ZSTD_error_dstSize_tooSmall:
return KTX_DECOMPRESS_LENGTH_ERROR; // inflatedDataCapacity too small.
result = KTX_DECOMPRESS_LENGTH_ERROR; // inflatedDataCapacity too small.
goto cleanup;
case ZSTD_error_checksum_wrong:
return KTX_DECOMPRESS_CHECKSUM_ERROR;
result = KTX_DECOMPRESS_CHECKSUM_ERROR;
goto cleanup;
case ZSTD_error_memory_allocation:
return KTX_OUT_OF_MEMORY;
result = KTX_OUT_OF_MEMORY;
goto cleanup;
default:
return KTX_FILE_DATA_ERROR;
result = KTX_FILE_DATA_ERROR;
goto cleanup;
}
}

Expand All @@ -2418,8 +2422,11 @@ ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb,
return result;
}

if (levelIndex[level].uncompressedByteLength != levelSize)
return KTX_DECOMPRESS_LENGTH_ERROR;
if (levelIndex[level].uncompressedByteLength != levelSize) {
result = KTX_DECOMPRESS_LENGTH_ERROR;
goto cleanup;
}


#if IS_BIG_ENDIAN
switch (prtctd->_typeSize) {
Expand Down