From: gameblabla Date: Thu, 18 Jul 2019 00:28:22 +0000 (+0200) Subject: psxbios: Add checks for strcpy & strncpy. X-Git-Tag: r23~156^2~23 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3d791f109093fb502a6674c13bd1196d94bca14;p=pcsx_rearmed.git psxbios: Add checks for strcpy & strncpy. This should be closer to documentation. --- diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index be3abb8c..13cfe733 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -630,6 +630,12 @@ void psxBios_strncmp() { // 0x18 void psxBios_strcpy() { // 0x19 char *p1 = (char *)Ra0, *p2 = (char *)Ra1; + if (a0 == 0 || a1 == 0) + { + v0 = 0; + pc0 = ra; + return; + } while ((*p1++ = *p2++) != '\0'); v0 = a0; pc0 = ra; @@ -638,7 +644,12 @@ void psxBios_strcpy() { // 0x19 void psxBios_strncpy() { // 0x1a char *p1 = (char *)Ra0, *p2 = (char *)Ra1; s32 n = a2, i; - + if (a0 == 0 || a1 == 0) + { + v0 = 0; + pc0 = ra; + return; + } for (i = 0; i < n; i++) { if ((*p1++ = *p2++) == '\0') { while (++i < n) {