summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/BPStructs.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2024-04-13 18:50:33 +0200
committerJosJuice <josjuice@gmail.com>2024-04-20 18:31:08 +0200
commitc204b33314802d5e5719990d76bccc87a1907c9d (patch)
tree4bd8f68c0f4319a671b4b947242c497fd255021e /Source/Core/VideoCommon/BPStructs.cpp
parent3cfa233b63dfcd734be2dd0ae4bd0d3e98109df6 (diff)
VideoCommon/BPStructs: Add a missing bounds check
Happened to find this when working on the previous commit.
Diffstat (limited to 'Source/Core/VideoCommon/BPStructs.cpp')
-rw-r--r--Source/Core/VideoCommon/BPStructs.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp
index 7eb6c88656..4f02c298b4 100644
--- a/Source/Core/VideoCommon/BPStructs.cpp
+++ b/Source/Core/VideoCommon/BPStructs.cpp
@@ -590,13 +590,16 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager, XFStateManager&
if (tmem_cfg.preload_tile_info.type != 3)
{
- bytes_read = tmem_cfg.preload_tile_info.count * TMEM_LINE_SIZE;
- if (tmem_addr_even + bytes_read > TMEM_SIZE)
- bytes_read = TMEM_SIZE - tmem_addr_even;
+ if (tmem_addr_even < TMEM_SIZE)
+ {
+ bytes_read = tmem_cfg.preload_tile_info.count * TMEM_LINE_SIZE;
+ if (tmem_addr_even + bytes_read > TMEM_SIZE)
+ bytes_read = TMEM_SIZE - tmem_addr_even;
- auto& system = Core::System::GetInstance();
- auto& memory = system.GetMemory();
- memory.CopyFromEmu(s_tex_mem.data() + tmem_addr_even, src_addr, bytes_read);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ memory.CopyFromEmu(s_tex_mem.data() + tmem_addr_even, src_addr, bytes_read);
+ }
}
else // RGBA8 tiles (and CI14, but that might just be stupid libogc!)
{