From 4b5ca6d4960addfff2d6e7d16427a18f61ad85f5 Mon Sep 17 00:00:00 2001 From: notmatthewbeshay <92357869+NotMachow@users.noreply.github.com> Date: Wed, 11 Mar 2026 03:24:51 +1100 Subject: [PATCH] Use standard colour table lengths in texture packs --- .../Textures/Packs/AbstractTexturePack.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp b/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp index 1ca33c9af..3605c4254 100644 --- a/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp @@ -4,6 +4,8 @@ #include "../../../Minecraft.World/IO/Streams/InputOutputStream.h" #include "../../../Minecraft.World/Util/StringHelpers.h" +#include + AbstractTexturePack::AbstractTexturePack(std::uint32_t id, File *file, const std::wstring &name, TexturePack *fallback) : id(id), name(name) { // 4J init @@ -257,14 +259,22 @@ void AbstractTexturePack::loadDefaultColourTable() if(coloursFile.exists()) { - DWORD dwLength = coloursFile.length(); - byteArray data(dwLength); + const __int64 colourTableLength = coloursFile.length(); + if(colourTableLength < 0 || colourTableLength > static_cast<__int64>(std::numeric_limits::max())) + { + app.DebugPrintf("Failed to load the default colours table\n"); + app.FatalLoadError(); + return; + } + + const unsigned int dataLength = static_cast(colourTableLength); + byteArray data(dataLength); FileInputStream fis(coloursFile); - fis.read(data,0,dwLength); + fis.read(data,0,dataLength); fis.close(); if(m_colourTable != NULL) delete m_colourTable; - m_colourTable = new ColourTable(data.data, dwLength); + m_colourTable = new ColourTable(data.data, dataLength); delete [] data.data; }