From 1f665cddc3500efa9a508a016fe656d570f1ee6a 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 a5a16a56..e46901cd 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -1433,7 +1433,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; } #ifndef _WIN32 @@ -1801,7 +1801,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.5