2
0
Эх сурвалжийг харах

Gracefully handle negative indexes in love.joystick (bug #172)

Bart van Strien 14 жил өмнө
parent
commit
98406370eb

+ 3 - 5
src/modules/joystick/sdl/Joystick.cpp

@@ -68,15 +68,13 @@ namespace sdl
 
 	bool Joystick::checkIndex(int index)
 	{
-		if(index < getNumJoysticks())
-			return true;
-		else
-			return false;
+		return index >= 0 && index < getNumJoysticks();
 	}
 
 	int Joystick::getNumJoysticks()
 	{
-		return SDL_NumJoysticks();
+		int num = SDL_NumJoysticks();
+		return num < 0 ? 0 : num;
 	}
 
 	const char * Joystick::getName(int index)