From c3d791f109093fb502a6674c13bd1196d94bca14 Mon Sep 17 00:00:00 2001 From: gameblabla Date: Thu, 18 Jul 2019 02:28:22 +0200 Subject: [PATCH] psxbios: Add checks for strcpy & strncpy. This should be closer to documentation. --- libpcsxcore/psxbios.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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) { -- 2.39.5