From 0eadc38917e77afb87c1e05beee8576a70b97ecf Mon Sep 17 00:00:00 2001 From: Logan McNaughton <848146+loganmc10@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:20:09 +0100 Subject: [PATCH] fix out-of-bound access in sram (#95) --- src/device/sram.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/device/sram.rs b/src/device/sram.rs index 9e54611..155ae4c 100644 --- a/src/device/sram.rs +++ b/src/device/sram.rs @@ -141,7 +141,7 @@ pub fn dma_read_sram( format_sram(device); - while i < dram_addr + length { + while i < dram_addr + length && i < device::rdram::RDRAM_SIZE as u32 { device.ui.saves.sram.0[j as usize] = device.rdram.mem[i as usize ^ device.byte_swap]; i += 1; j += 1; @@ -191,7 +191,7 @@ pub fn dma_write_sram( format_sram(device); - while i < dram_addr + length { + while i < dram_addr + length && i < device::rdram::RDRAM_SIZE as u32 { device.rdram.mem[i as usize ^ device.byte_swap] = device.ui.saves.sram.0[j as usize]; i += 1; j += 1;