diff options
author | gameblabla | 2019-07-18 02:16:41 +0200 |
---|---|---|
committer | gameblabla | 2019-07-18 02:16:41 +0200 |
commit | ef1da3dc02d5c3683cca34f1f5c59ca1b2134c72 (patch) | |
tree | 4c3e9914dd110e7c310d4ecd324d05a0e2f0f34c | |
parent | 01724d23d3e65e6ca12f3800d79c7de6ec241ea2 (diff) | |
download | pcsx_rearmed-ef1da3dc02d5c3683cca34f1f5c59ca1b2134c72.tar.gz pcsx_rearmed-ef1da3dc02d5c3683cca34f1f5c59ca1b2134c72.tar.bz2 pcsx_rearmed-ef1da3dc02d5c3683cca34f1f5c59ca1b2134c72.zip |
psxbios: Add checks to memcpy.
Always returns dst
-rw-r--r-- | libpcsxcore/psxbios.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index c362a75..b327632 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -788,9 +788,19 @@ void psxBios_bcmp() { // 0x29 void psxBios_memcpy() { // 0x2a char *p1 = (char *)Ra0, *p2 = (char *)Ra1; - while ((s32)a2-- > 0) *p1++ = *p2++; - - v0 = a0; pc0 = ra; + s32 n=0; + v0 = a0; + if (a0 == 0 || a2 > 0x7FFFFFFF) + { + pc0 = ra; + return; + } + while ((s32)a2-- > 0) { + n++; + *p1++ = *p2++; + } + a2 = 0; + pc0 = ra; } void psxBios_memset() { // 0x2b |