From b7209eafb17abc9f6a570346f151def453cb7632 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 6 Oct 2019 00:37:31 +1000 Subject: [PATCH] GPU: Fix out-of-bounds read in GP1(10h) --- src/core/gpu.cpp | 6 +++--- src/core/gpu.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index de03f3f56..2f3d70781 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -615,7 +615,7 @@ void GPU::WriteGP1(u32 value) case 0x1E: case 0x1F: { - HandleGetGPUInfoCommand(); + HandleGetGPUInfoCommand(value); } break; @@ -625,9 +625,9 @@ void GPU::WriteGP1(u32 value) } } -void GPU::HandleGetGPUInfoCommand() +void GPU::HandleGetGPUInfoCommand(u32 value) { - const u8 subcommand = Truncate8(m_GP0_command[0] & 0x07); + const u8 subcommand = Truncate8(value & 0x07); switch (subcommand) { case 0x00: diff --git a/src/core/gpu.h b/src/core/gpu.h index ebd43c9e3..4e38e35d8 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -181,7 +181,7 @@ protected: u32 ReadGPUREAD(); void WriteGP0(u32 value); void WriteGP1(u32 value); - void HandleGetGPUInfoCommand(); + void HandleGetGPUInfoCommand(u32 value); // Rendering commands, returns false if not enough data is provided bool HandleRenderCommand();