Skip to content

Commit 95d226e

Browse files
committed
xrGame/sound_player.cpp: make random() more safe (#1799)
Don't read out of bounds. If id is bigger than the number of elements, just select random sound just like if -1 is being passed
1 parent 0a7afb5 commit 95d226e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/xrGame/sound_player.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,9 @@ const ref_sound& CSoundPlayer::CSoundCollection::random(u32 id)
287287
{
288288
VERIFY(!m_sounds.empty());
289289

290-
if (id != u32(-1))
290+
if (id != u32(-1) && id < m_sounds.size())
291291
{
292292
m_last_sound_id = id;
293-
VERIFY(id < m_sounds.size());
294293
return (*m_sounds[id]);
295294
}
296295

0 commit comments

Comments
 (0)