diff --git a/src/SFML/Window/Joystick.cpp b/src/SFML/Window/Joystick.cpp index ca6818635..9989e3e8a 100644 --- a/src/SFML/Window/Joystick.cpp +++ b/src/SFML/Window/Joystick.cpp @@ -28,6 +28,8 @@ #include #include +#include + namespace sf { @@ -55,6 +57,7 @@ bool Joystick::hasAxis(unsigned int joystick, Axis axis) //////////////////////////////////////////////////////////// bool Joystick::isButtonPressed(unsigned int joystick, unsigned int button) { + assert(button < Joystick::ButtonCount && "Button must be less than Joystick::ButtonCount"); return priv::JoystickManager::getInstance().getState(joystick).buttons[button]; } diff --git a/src/SFML/Window/JoystickManager.cpp b/src/SFML/Window/JoystickManager.cpp index 1719cd731..c6e5b3dab 100644 --- a/src/SFML/Window/JoystickManager.cpp +++ b/src/SFML/Window/JoystickManager.cpp @@ -27,6 +27,8 @@ //////////////////////////////////////////////////////////// #include +#include + namespace sf::priv { @@ -41,6 +43,7 @@ JoystickManager& JoystickManager::getInstance() //////////////////////////////////////////////////////////// const JoystickCaps& JoystickManager::getCapabilities(unsigned int joystick) const { + assert(joystick < Joystick::Count && "Joystick index must be less than Joystick::Count"); return m_joysticks[joystick].capabilities; } @@ -48,6 +51,7 @@ const JoystickCaps& JoystickManager::getCapabilities(unsigned int joystick) cons //////////////////////////////////////////////////////////// const JoystickState& JoystickManager::getState(unsigned int joystick) const { + assert(joystick < Joystick::Count && "Joystick index must be less than Joystick::Count"); return m_joysticks[joystick].state; } @@ -55,6 +59,7 @@ const JoystickState& JoystickManager::getState(unsigned int joystick) const //////////////////////////////////////////////////////////// const Joystick::Identification& JoystickManager::getIdentification(unsigned int joystick) const { + assert(joystick < Joystick::Count && "Joystick index must be less than Joystick::Count"); return m_joysticks[joystick].identification; }