From c5cb603315a4705ebaebf0c3cfa52e33a81067e1 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 1 Oct 2024 19:36:25 +0300 Subject: [PATCH] psxmem: fix map retry breakage fixes 417b59ebc326fc753f8c881c24fc7aff975df7ea --- libpcsxcore/psxmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index a70cc623..a8dfaa83 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -90,10 +90,12 @@ void *psxMap(unsigned long addr, size_t size, int is_fixed, enum psxMapTag tag) { int try_, can_retry_addr = 0; - void *ret; + void *ret = MAP_FAILED; for (try_ = 0; try_ < 3; try_++) { + if (ret != MAP_FAILED) + psxUnmap(ret, size, tag); ret = psxMapHook(addr, size, tag, &can_retry_addr); if (ret == NULL) return MAP_FAILED; @@ -109,8 +111,6 @@ void *psxMap(unsigned long addr, size_t size, int is_fixed, if (can_retry_addr && ((addr ^ (uintptr_t)ret) & ~0xff000000l)) { unsigned long mask; - psxUnmap(ret, size, tag); - // try to use similarly aligned memory instead // (recompiler prefers this) mask = try_ ? 0xffff : 0xffffff; -- 2.39.5