Assert against UB in sf::Touch::getPosition

This commit is contained in:
Chris Thrasher 2024-05-12 20:38:14 -05:00
parent c38b98c653
commit c96cb59845
No known key found for this signature in database
GPG Key ID: 56FB686C9DFC8E2C

View File

@ -28,6 +28,8 @@
#include <SFML/Window/InputImpl.hpp>
#include <SFML/Window/Touch.hpp>
#include <cassert>
namespace sf::Touch
{
@ -41,6 +43,7 @@ bool isDown(unsigned int finger)
////////////////////////////////////////////////////////////
Vector2i getPosition(unsigned int finger)
{
assert(isDown(finger) && "Touch::getPosition() Finger must already be down");
return priv::InputImpl::getTouchPosition(finger);
}
@ -48,6 +51,7 @@ Vector2i getPosition(unsigned int finger)
////////////////////////////////////////////////////////////
Vector2i getPosition(unsigned int finger, const WindowBase& relativeTo)
{
assert(isDown(finger) && "Touch::getPosition() Finger must already be down");
return priv::InputImpl::getTouchPosition(finger, relativeTo);
}