From 02aac2c52eb2c2aac2418d683bf270e50c0529b3 Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi <18193363+elad335@users.noreply.github.com> Date: Sun, 28 Jul 2024 11:26:44 +0300 Subject: [PATCH] sys_fs: Non-existant overflow bugfix It would technically never overflow.. but this add minimal protection against adding beyond [PPU thread-count + entries count] This does not induce an atomic loop which limits until entries.size() but is slower. --- rpcs3/Emu/Cell/lv2/sys_fs.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.h b/rpcs3/Emu/Cell/lv2/sys_fs.h index 32aa6010a6..d6acb6361b 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.h +++ b/rpcs3/Emu/Cell/lv2/sys_fs.h @@ -384,7 +384,9 @@ struct lv2_dir final : lv2_fs_object // Read next const fs::dir_entry* dir_read() { - if (const u64 cur = pos++; cur < entries.size()) + const u64 old_pos = pos; + + if (const u64 cur = (old_pos < entries.size() ? pos++ : old_pos); cur < entries.size()) { return &entries[cur]; }