From 0148ffb739a05e87ed9eaaf623c754d3d50ee2ab Mon Sep 17 00:00:00 2001 From: gameblabla Date: Thu, 18 Jul 2019 02:13:13 +0200 Subject: [PATCH] psxbios: Add checks for bcopy Nocash documentation say that function refuses to copy any data if dst is NULL or len greater than 0x7FFFFFFF. (In any cases, return value is always dst) --- libpcsxcore/psxbios.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index 67a01e5a..4019234b 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -739,15 +739,20 @@ void psxBios_tolower() { // 0x26 void psxBios_bcopy() { // 0x27 char *p1 = (char *)Ra1, *p2 = (char *)Ra0; + v0 = a0; + if (a0 == 0 || a2 > 0x7FFFFFFF) + { + pc0 = ra; + return; + } while ((s32)a2-- > 0) *p1++ = *p2++; - + a2 = 0; pc0 = ra; } void psxBios_bzero() { // 0x28 char *p = (char *)Ra0; while ((s32)a1-- > 0) *p++ = '\0'; - pc0 = ra; } -- 2.39.5