Skip to content

Commit 451dbb1

Browse files
committed
Engine: Add missing range checks
1 parent 0c96f70 commit 451dbb1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/engine/engine.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ void Engine::setBroadcasts(const std::vector<std::shared_ptr<Broadcast>> &broadc
408408

409409
std::shared_ptr<Broadcast> Engine::broadcastAt(int index) const
410410
{
411+
if (index < 0 || index >= m_broadcasts.size())
412+
return nullptr;
413+
411414
return m_broadcasts[index];
412415
}
413416

@@ -469,6 +472,9 @@ void Engine::setTargets(const std::vector<std::shared_ptr<Target>> &newTargets)
469472

470473
Target *Engine::targetAt(int index) const
471474
{
475+
if (index < 0 || index >= m_targets.size())
476+
return nullptr;
477+
472478
return m_targets[index].get();
473479
}
474480

0 commit comments

Comments
 (0)