Skip to content

Commit 7d98959

Browse files
authored
1 parent cc74757 commit 7d98959

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/texture2.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,13 +2393,17 @@ ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb,
23932393
ZSTD_ErrorCode error = ZSTD_getErrorCode(levelSize);
23942394
switch(error) {
23952395
case ZSTD_error_dstSize_tooSmall:
2396-
return KTX_DECOMPRESS_LENGTH_ERROR; // inflatedDataCapacity too small.
2396+
result = KTX_DECOMPRESS_LENGTH_ERROR; // inflatedDataCapacity too small.
2397+
goto cleanup;
23972398
case ZSTD_error_checksum_wrong:
2398-
return KTX_DECOMPRESS_CHECKSUM_ERROR;
2399+
result = KTX_DECOMPRESS_CHECKSUM_ERROR;
2400+
goto cleanup;
23992401
case ZSTD_error_memory_allocation:
2400-
return KTX_OUT_OF_MEMORY;
2402+
result = KTX_OUT_OF_MEMORY;
2403+
goto cleanup;
24012404
default:
2402-
return KTX_FILE_DATA_ERROR;
2405+
result = KTX_FILE_DATA_ERROR;
2406+
goto cleanup;
24032407
}
24042408
}
24052409

@@ -2418,8 +2422,11 @@ ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb,
24182422
return result;
24192423
}
24202424

2421-
if (levelIndex[level].uncompressedByteLength != levelSize)
2422-
return KTX_DECOMPRESS_LENGTH_ERROR;
2425+
if (levelIndex[level].uncompressedByteLength != levelSize) {
2426+
result = KTX_DECOMPRESS_LENGTH_ERROR;
2427+
goto cleanup;
2428+
}
2429+
24232430

24242431
#if IS_BIG_ENDIAN
24252432
switch (prtctd->_typeSize) {

0 commit comments

Comments
 (0)