diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index dbd53865b..7f1dbd971 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -416,6 +416,7 @@ static void import_texture_rgba32(int tile) { static void import_texture_rgba16(int tile) { tile = tile % RDP_TILES; if (!rdp.loaded_texture[tile].addr) { return; } + if (rdp.loaded_texture[tile].size_bytes * 2 > 8192) { return; } uint8_t rgba32_buf[8192]; for (uint32_t i = 0; i < rdp.loaded_texture[tile].size_bytes / 2; i++) { @@ -439,6 +440,7 @@ static void import_texture_rgba16(int tile) { static void import_texture_ia4(int tile) { tile = tile % RDP_TILES; if (!rdp.loaded_texture[tile].addr) { return; } + if (rdp.loaded_texture[tile].size_bytes * 8 > 32768) { return; } uint8_t rgba32_buf[32768]; for (uint32_t i = 0; i < rdp.loaded_texture[tile].size_bytes * 2; i++) { @@ -464,6 +466,7 @@ static void import_texture_ia4(int tile) { static void import_texture_ia8(int tile) { tile = tile % RDP_TILES; if (!rdp.loaded_texture[tile].addr) { return; } + if (rdp.loaded_texture[tile].size_bytes * 4 > 16384) { return; } uint8_t rgba32_buf[16384]; for (uint32_t i = 0; i < rdp.loaded_texture[tile].size_bytes; i++) { @@ -487,6 +490,7 @@ static void import_texture_ia8(int tile) { static void import_texture_ia16(int tile) { tile = tile % RDP_TILES; if (!rdp.loaded_texture[tile].addr) { return; } + if (rdp.loaded_texture[tile].size_bytes * 2 > 8192) { return; } uint8_t rgba32_buf[8192]; for (uint32_t i = 0; i < rdp.loaded_texture[tile].size_bytes / 2; i++) { @@ -510,6 +514,7 @@ static void import_texture_ia16(int tile) { static void import_texture_i4(int tile) { tile = tile % RDP_TILES; if (!rdp.loaded_texture[tile].addr) { return; } + if (rdp.loaded_texture[tile].size_bytes * 8 > 32768) { return; } uint8_t rgba32_buf[32768]; for (uint32_t i = 0; i < rdp.loaded_texture[tile].size_bytes * 2; i++) { @@ -530,6 +535,7 @@ static void import_texture_i4(int tile) { static void import_texture_i8(int tile) { tile = tile % RDP_TILES; if (!rdp.loaded_texture[tile].addr) { return; } + if (rdp.loaded_texture[tile].size_bytes * 4 > 16384) { return; } uint8_t rgba32_buf[16384]; for (uint32_t i = 0; i < rdp.loaded_texture[tile].size_bytes; i++) { @@ -549,6 +555,7 @@ static void import_texture_i8(int tile) { static void import_texture_ci4(int tile) { tile = tile % RDP_TILES; if (!rdp.loaded_texture[tile].addr) { return; } + if (rdp.loaded_texture[tile].size_bytes * 8 > 32768) { return; } uint8_t rgba32_buf[32768]; for (uint32_t i = 0; i < rdp.loaded_texture[tile].size_bytes * 2; i++) { @@ -574,6 +581,7 @@ static void import_texture_ci4(int tile) { static void import_texture_ci8(int tile) { tile = tile % RDP_TILES; if (!rdp.loaded_texture[tile].addr) { return; } + if (rdp.loaded_texture[tile].size_bytes * 4 > 16384) { return; } uint8_t rgba32_buf[16384]; for (uint32_t i = 0; i < rdp.loaded_texture[tile].size_bytes; i++) {