Fix cheevos crash when peeking out of range

This would occur if the address being peeked at was not part of a memory region defined in the core.
This commit is contained in:
Raphaël Zumer 2019-04-06 13:48:18 -04:00 committed by GitHub
parent 9579804c72
commit e181bc6d39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -527,11 +527,14 @@ static unsigned cheevos_peek(unsigned address, unsigned num_bytes, void* ud)
address, cheevos_locals.patchdata.console_id);
unsigned value = 0;
switch (num_bytes)
if (data)
{
case 4: value |= data[2] << 16 | data[3] << 24;
case 2: value |= data[1] << 8;
case 1: value |= data[0];
switch (num_bytes)
{
case 4: value |= data[2] << 16 | data[3] << 24;
case 2: value |= data[1] << 8;
case 1: value |= data[0];
}
}
return value;