From 8d41249f6f271b146ee6b378de7420240c444f08 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 13 Apr 2025 23:01:05 +0300 Subject: [PATCH] rsx: Fix simple_array::erase_if --- rpcs3/Emu/RSX/Common/simple_array.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/simple_array.hpp b/rpcs3/Emu/RSX/Common/simple_array.hpp index 0fec530852..aa482ef418 100644 --- a/rpcs3/Emu/RSX/Common/simple_array.hpp +++ b/rpcs3/Emu/RSX/Common/simple_array.hpp @@ -390,14 +390,22 @@ namespace rsx } bool ret = false; - for (auto ptr = _data, last = _data + _size - 1; ptr < last; ptr++) + for (auto ptr = _data, last = _data + _size - 1; ptr <= last; ptr++) { if (predicate(*ptr)) { + ret = true; + + if (ptr == last) + { + // Popping the last entry from list. Just set the new size and exit + _size--; + break; + } + // Move item to the end of the list and shrink by 1 std::memcpy(ptr, last, sizeof(Ty)); last = _data + (--_size); - ret = true; } }