From: notaz Date: Tue, 1 Oct 2024 16:36:25 +0000 (+0300) Subject: psxmem: fix map retry breakage X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b2c3926522942d76fda85db22c6fa5e13cf4ce9;p=pcsx_rearmed.git psxmem: fix map retry breakage fixes 417b59ebc326fc753f8c881c24fc7aff975df7ea --- 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;