master #5

Merged
BRNSystems merged 45 commits from Mirrorlandia_minetest/irrlicht:master into master 2024-02-27 13:26:18 +01:00
Showing only changes of commit 0dab737d60 - Show all commits

@ -10,6 +10,7 @@
#include "CImage.h" #include "CImage.h"
#include "irrString.h" #include "irrString.h"
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
namespace irr namespace irr
{ {
@ -138,7 +139,8 @@ IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const
if (header.ColorMapType) if (header.ColorMapType)
{ {
// Create 32 bit palette // Create 32 bit palette
const irr::u16 paletteSize = core::max_((u16)256, header.ColorMapLength); // ColorMapLength can lie, but so far we only use palette for 8-bit, so ensure it has 256 entries // `core::max_()` is not used here because it takes its inputs as references. Since `header` is packed, use the macro `MAX()` instead:
const irr::u16 paletteSize = MAX((u16)256u, header.ColorMapLength); // ColorMapLength can lie, but so far we only use palette for 8-bit, so ensure it has 256 entries
palette = new u32[paletteSize]; palette = new u32[paletteSize];
if( paletteSize > header.ColorMapLength ) if( paletteSize > header.ColorMapLength )