From e0f25b64cf98406b7059b373b04a18b45e2a0aa7 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 22 Oct 2022 19:20:26 +0300 Subject: [PATCH] cdrom: report read errors correctly --- libpcsxcore/cdriso.c | 4 ++-- libpcsxcore/cdrom.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index 246b6a06..2a31950f 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -1238,7 +1238,7 @@ static int cdread_2048(FILE *f, unsigned int base, void *dest, int sector) sec2msf(sector + 2 * 75, (char *)&cdbuffer[12]); cdbuffer[12 + 3] = 1; - return ret; + return 12*2 + ret; } static unsigned char * CALLBACK ISOgetBuffer_compr(void) { @@ -1540,7 +1540,7 @@ static boolean CALLBACK ISOreadTrack(unsigned char *time) { } ret = cdimg_read_func(cdHandle, 0, cdbuffer, sector); - if (ret < 0) + if (ret < 12*2 + 2048) return 0; if (subHandle != NULL) { diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index b3e238b6..41dc1513 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -463,7 +463,8 @@ static int ReadTrack(const u8 *time) { CDR_LOG("ReadTrack *** %02x:%02x:%02x\n", tmp[0], tmp[1], tmp[2]); read_ok = CDR_readTrack(tmp); - memcpy(cdr.Prev, tmp, 3); + if (read_ok) + memcpy(cdr.Prev, tmp, 3); if (CheckSBI(time)) return read_ok; @@ -1253,7 +1254,6 @@ static void cdrReadInterrupt(void) if (!read_ok) { CDR_LOG_I("cdrReadInterrupt() Log: err\n"); - memset(cdr.Transfer, 0, DATA_SIZE); cdrReadInterruptSetResult(cdr.StatP | STATUS_ERROR); return; } -- 2.39.2