Skip to content

Commit 7a5603b

Browse files
committed
Add bounds checks on Dreamcast SFX retry-delay array access
Prevent out-of-bounds access if the sgSFX vector index exceeds the fixed-size SfxLoadRetryAfterMs array. Signed-off-by: Panagiotis Georgiadis <pgeorgia@redhat.com>
1 parent af95503 commit 7a5603b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Source/effects.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,16 @@ size_t GetSfxIndex(const TSFX *sfx)
6565
bool ShouldAttemptSfxLoadNow(const TSFX *sfx)
6666
{
6767
const size_t index = GetSfxIndex(sfx);
68+
if (index >= SfxLoadRetryAfterMs.size())
69+
return true;
6870
return SDL_GetTicks() >= SfxLoadRetryAfterMs[index];
6971
}
7072

7173
void DeferSfxLoad(const TSFX *sfx, uint32_t delayMs)
7274
{
7375
const size_t index = GetSfxIndex(sfx);
76+
if (index >= SfxLoadRetryAfterMs.size())
77+
return;
7478
SfxLoadRetryAfterMs[index] = SDL_GetTicks() + delayMs;
7579
}
7680

0 commit comments

Comments
 (0)