psxbios : Add checks to index and rindex calls
authorgameblabla <gameblabla@openmailbox.org>
Thu, 18 Jul 2019 00:12:23 +0000 (02:12 +0200)
committergameblabla <gameblabla@openmailbox.org>
Thu, 18 Jul 2019 00:12:23 +0000 (02:12 +0200)
Return 0 for index/rindex if src is 0x00.

libpcsxcore/psxbios.c

index 010a229..67a01e5 100644 (file)
@@ -610,7 +610,13 @@ void psxBios_strlen() { // 0x1b
 
 void psxBios_index() { // 0x1c
        char *p = (char *)Ra0;
-
+       if (a0 == 0)
+       {
+               v0 = 0;
+               pc0 = ra;
+               return;
+       }
+       
        do {
                if (*p == a1) {
                        v0 = a0 + (p - (char *)Ra0);
@@ -626,7 +632,11 @@ void psxBios_rindex() { // 0x1d
        char *p = (char *)Ra0;
 
        v0 = 0;
-
+       if (a0 == 0)
+       {
+               pc0 = ra;
+               return;
+       }
        do {
                if (*p == a1)
                        v0 = a0 + (p - (char *)Ra0);