Fix leak in SDL_GameControllerTypeForIndex()
This commit is contained in:
1 parent
f9435eab16
commit
398bacbac3
1 file changed
+3
-1
@@ -1984,7 +1984,7 @@ const char *SDL_GameControllerPathForIndex(int joystick_index)
|
|||||||
SDL_GameControllerType SDL_GameControllerTypeForIndex(int joystick_index)
|
SDL_GameControllerType SDL_GameControllerTypeForIndex(int joystick_index)
|
||||||
{
|
{
|
||||||
SDL_JoystickGUID joystick_guid = SDL_JoystickGetDeviceGUID(joystick_index);
|
SDL_JoystickGUID joystick_guid = SDL_JoystickGetDeviceGUID(joystick_index);
|
||||||
const char *mapping = SDL_GameControllerMappingForGUID(joystick_guid);
|
char *mapping = SDL_GameControllerMappingForGUID(joystick_guid);
|
||||||
char *type_string, *comma;
|
char *type_string, *comma;
|
||||||
SDL_GameControllerType type;
|
SDL_GameControllerType type;
|
||||||
if (mapping) {
|
if (mapping) {
|
||||||
@@ -1999,8 +1999,10 @@ SDL_GameControllerType SDL_GameControllerTypeForIndex(int joystick_index)
|
|||||||
} else {
|
} else {
|
||||||
type = SDL_GetGameControllerTypeFromString(type_string);
|
type = SDL_GetGameControllerTypeFromString(type_string);
|
||||||
}
|
}
|
||||||
|
SDL_free(mapping);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
SDL_free(mapping);
|
||||||
}
|
}
|
||||||
return SDL_GetJoystickGameControllerTypeFromGUID(joystick_guid, SDL_JoystickNameForIndex(joystick_index));
|
return SDL_GetJoystickGameControllerTypeFromGUID(joystick_guid, SDL_JoystickNameForIndex(joystick_index));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user