From 00e692901132f23fcb1c36f660a6e1f0c889c0f3 Mon Sep 17 00:00:00 2001 From: Justin Weiss Date: Mon, 28 Sep 2020 18:12:17 -0700 Subject: [PATCH] Correctly signal errors for out-of-bounds async CD reads --- libpcsxcore/cdriso.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index c8eacb87..6c6d8356 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -1260,14 +1260,19 @@ static void *readThreadMain(void *param) { last_read_sector = requested_sector_end; } + index = ra_sector % SECTOR_BUFFER_SIZE; + // check for end of CD if (ra_count && ra_sector >= max_sector) { ra_count = 0; + pthread_mutex_lock(§orbuffer_lock); + sectorbuffer[index].ret = -1; + sectorbuffer[index].sector = ra_sector; + pthread_cond_signal(§orbuffer_cond); + pthread_mutex_unlock(§orbuffer_lock); } if (ra_count) { - - index = ra_sector % SECTOR_BUFFER_SIZE; pthread_mutex_lock(§orbuffer_lock); if (sectorbuffer[index].sector != ra_sector) { pthread_mutex_unlock(§orbuffer_lock); -- 2.39.5