From a675806c91dad63a6c4f635e7ed6cc3cf951aac1 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 11 Dec 2023 07:06:12 +0300 Subject: [PATCH] engine: imagelib: img_ktx2: don't allow to load images with no mip levels --- engine/common/imagelib/img_ktx2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engine/common/imagelib/img_ktx2.c b/engine/common/imagelib/img_ktx2.c index a33f563b..04f30657 100644 --- a/engine/common/imagelib/img_ktx2.c +++ b/engine/common/imagelib/img_ktx2.c @@ -87,6 +87,12 @@ static qboolean Image_KTX2Parse( const ktx2_header_t *header, const byte *buffer return false; } + if( header->levelCount == 0 ) + { + Con_DPrintf( S_ERROR "%s: file has no mip levels\n", __FUNCTION__ ); + return false; + } + if( header->pixelDepth > 1 ) { Con_DPrintf( S_ERROR "%s: unsupported KTX2 pixelDepth %d\n", __FUNCTION__, header->pixelDepth );