From e181bc6d3971faf31b6c2f4f50aa0f3a8103095b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Zumer?= Date: Sat, 6 Apr 2019 13:48:18 -0400 Subject: [PATCH] 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. --- cheevos-new/cheevos.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cheevos-new/cheevos.c b/cheevos-new/cheevos.c index 435a154f08..5276d006d4 100644 --- a/cheevos-new/cheevos.c +++ b/cheevos-new/cheevos.c @@ -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;