From: gameblabla Date: Thu, 18 Jul 2019 00:19:07 +0000 (+0200) Subject: psxbios: Add checks for memmove. X-Git-Tag: r23~156^2~28 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=112dddf5f26989d55b257f51bdcb9236bc7c1de0;p=pcsx_rearmed.git psxbios: Add checks for memmove. Always returns dst per documentation. --- diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index 97c79519..399df9a4 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -824,7 +824,12 @@ void psxBios_memset() { // 0x2b void psxBios_memmove() { // 0x2c char *p1 = (char *)Ra0, *p2 = (char *)Ra1; - + v0 = a0; + if (a0 == 0 || a2 > 0x7FFFFFFF) + { + pc0 = ra; + return; + } if (p2 <= p1 && p2 + a2 > p1) { a2++; // BUG: copy one more byte here p1 += a2; @@ -833,8 +838,7 @@ void psxBios_memmove() { // 0x2c } else { while ((s32)a2-- > 0) *p1++ = *p2++; } - - v0 = a0; pc0 = ra; + pc0 = ra; } void psxBios_memcmp() { // 0x2d