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.
This commit is contained in:
Elad Ashkenazi 2024-07-28 11:26:44 +03:00
parent faabb9e111
commit 02aac2c52e
1 changed files with 3 additions and 1 deletions

View File

@ -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];
}