Fix minor memory leak in Gamepad
This commit is contained in:
@@ -793,7 +793,18 @@ namespace lime {
|
||||
value lime_gamepad_get_device_guid (int id) {
|
||||
|
||||
const char* guid = Gamepad::GetDeviceGUID (id);
|
||||
return guid ? alloc_string (guid) : alloc_null ();
|
||||
|
||||
if (guid) {
|
||||
|
||||
value result = alloc_string (guid);
|
||||
delete guid;
|
||||
return result;
|
||||
|
||||
} else {
|
||||
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,17 @@ namespace lime {
|
||||
|
||||
const char* Gamepad::GetDeviceGUID (int id) {
|
||||
|
||||
char* guid = new char[64];
|
||||
SDL_Joystick* joystick = SDL_GameControllerGetJoystick (gameControllers[id]);
|
||||
SDL_JoystickGetGUIDString (SDL_JoystickGetGUID (joystick), guid, 64);
|
||||
return guid;
|
||||
|
||||
if (joystick) {
|
||||
|
||||
char* guid = new char[64];
|
||||
SDL_JoystickGetGUIDString (SDL_JoystickGetGUID (joystick), guid, 64);
|
||||
return guid;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user