From a0b671d5908c5f4523cf28ff50a6dcd35e3a549f Mon Sep 17 00:00:00 2001 From: inspectredc Date: Thu, 28 Nov 2024 13:37:08 +0000 Subject: [PATCH] Fix Mio0 Encoding In Compressed Texture Factory --- src/factories/CompressedTextureFactory.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/factories/CompressedTextureFactory.cpp b/src/factories/CompressedTextureFactory.cpp index c13eb10..4d30bc2 100644 --- a/src/factories/CompressedTextureFactory.cpp +++ b/src/factories/CompressedTextureFactory.cpp @@ -118,10 +118,12 @@ ExportResult CompressedTextureCodeExporter::Export(std::ostream &write, std::sha // Allocate worse case size uint8_t* compressedData; size_t compressedSize; + size_t worstSize; switch (texture->mCompressionType) { case CompressionType::MIO0: - compressedData = static_cast(malloc(MIO0_HEADER_LENGTH + ((data.size()+7)/8) + data.size())); + worstSize = MIO0_HEADER_LENGTH + ((data.size()+7)/8) + data.size(); + compressedData = static_cast(std::calloc(worstSize, sizeof(uint8_t))); compressedSize = mio0_encode(data.data(), data.size(), compressedData); break; default: