From 01724d23d3e65e6ca12f3800d79c7de6ec241ea2 Mon Sep 17 00:00:00 2001 From: gameblabla Date: Thu, 18 Jul 2019 02:15:27 +0200 Subject: [PATCH] psxbios: Add checks for bzero. Only return 0 if size is invalid. (0 or 0x7FFFFFFF), return dst if not. --- libpcsxcore/psxbios.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index 4019234b..c362a759 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -752,7 +752,21 @@ void psxBios_bcopy() { // 0x27 void psxBios_bzero() { // 0x28 char *p = (char *)Ra0; + v0 = a0; + /* Same as memset here (See memset below) */ + if (a1 > 0x7FFFFFFF || a1 == 0) + { + v0 = 0; + pc0 = ra; + return; + } + else if (a0 == 0) + { + pc0 = ra; + return; + } while ((s32)a1-- > 0) *p++ = '\0'; + a1 = 0; pc0 = ra; } -- 2.39.5