mirror of
https://github.com/n64dev/cen64.git
synced 2024-06-15 10:37:48 -04:00
Avoid length overflow when fetch starts beyond ROM
This commit is contained in:
parent
0902da8113
commit
d386930fa2
|
@ -90,7 +90,9 @@ static int pi_dma_read(struct pi_controller *pi) {
|
|||
|
||||
static void pi_rom_fetch(struct pi_controller *pi, uint32_t source, int32_t length, uint8_t *dest) {
|
||||
int l = length;
|
||||
if (source + length > pi->rom_size)
|
||||
if (source >= pi->rom_size)
|
||||
l = 0;
|
||||
else if (source + length > pi->rom_size)
|
||||
l = pi->rom_size - source;
|
||||
memcpy(dest, pi->rom + source, l);
|
||||
|
||||
|
|
Loading…
Reference in a new issue