diff --git a/libs/filaflat/src/MaterialChunk.cpp b/libs/filaflat/src/MaterialChunk.cpp index c4689748f5d2..455265fc01bc 100644 --- a/libs/filaflat/src/MaterialChunk.cpp +++ b/libs/filaflat/src/MaterialChunk.cpp @@ -186,6 +186,9 @@ bool MaterialChunk::getTextShader(Unflattener unflattener, if (!unflattener.read(&shaderSize)){ return false; } + if (shaderSize == 0) { + return false; + } // Read how many lines there are. uint32_t lineCount = 0; diff --git a/libs/image/src/Ktx1Bundle.cpp b/libs/image/src/Ktx1Bundle.cpp index bebc04328898..d0b293f3b377 100644 --- a/libs/image/src/Ktx1Bundle.cpp +++ b/libs/image/src/Ktx1Bundle.cpp @@ -106,7 +106,10 @@ Ktx1Bundle::Ktx1Bundle(uint32_t numMipLevels, uint32_t arrayLength, bool isCubem mNumMipLevels = numMipLevels; mArrayLength = arrayLength; mNumCubeFaces = isCubemap ? 6 : 1; - mBlobs->sizes.resize(numMipLevels * arrayLength * mNumCubeFaces); + uint64_t const totalBlobs = (uint64_t)numMipLevels * arrayLength * mNumCubeFaces; + FILAMENT_CHECK_POSTCONDITION(totalBlobs <= (uint64_t)std::numeric_limits::max()) + << "KTX dimensions overflow"; + mBlobs->sizes.resize((uint32_t)totalBlobs); } Ktx1Bundle::Ktx1Bundle(uint8_t const* bytes, uint32_t nbytes) :