mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Fixed some potential instability or crash issues
This commit is contained in:
@@ -42,7 +42,8 @@ Joystick::Joystick()
|
||||
|
||||
// Open all connected joysticks.
|
||||
int numjoysticks = this->getNumJoysticks();
|
||||
this->joysticks = (SDL_Joystick **)calloc(numjoysticks, sizeof(SDL_Joystick *));
|
||||
if (numjoysticks > 0)
|
||||
this->joysticks = (SDL_Joystick **)calloc(numjoysticks, sizeof(SDL_Joystick *));
|
||||
|
||||
for (int i = 0; i<numjoysticks; i++)
|
||||
this->open(i);
|
||||
@@ -79,7 +80,8 @@ void Joystick::reload()
|
||||
throw love::Exception("%s", SDL_GetError());
|
||||
|
||||
int numjoysticks = this->getNumJoysticks();
|
||||
this->joysticks = (SDL_Joystick **)calloc(numjoysticks, sizeof(SDL_Joystick *));
|
||||
if (numjoysticks > 0)
|
||||
this->joysticks = (SDL_Joystick **)calloc(numjoysticks, sizeof(SDL_Joystick *));
|
||||
|
||||
for (int i = 0; i<numjoysticks; i++)
|
||||
this->open(i);
|
||||
|
||||
Reference in New Issue
Block a user