Skip to content

Commit 6e5cad8

Browse files
Sackzementslouken
authored andcommitted
Fix leak in SDL_GameControllerTypeForIndex()
(cherry picked from commit 398bacb)
1 parent 876baf6 commit 6e5cad8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/joystick/SDL_gamecontroller.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ const char *SDL_GameControllerPathForIndex(int joystick_index)
19841984
SDL_GameControllerType SDL_GameControllerTypeForIndex(int joystick_index)
19851985
{
19861986
SDL_JoystickGUID joystick_guid = SDL_JoystickGetDeviceGUID(joystick_index);
1987-
const char *mapping = SDL_GameControllerMappingForGUID(joystick_guid);
1987+
char *mapping = SDL_GameControllerMappingForGUID(joystick_guid);
19881988
char *type_string, *comma;
19891989
SDL_GameControllerType type;
19901990
if (mapping) {
@@ -1999,8 +1999,10 @@ SDL_GameControllerType SDL_GameControllerTypeForIndex(int joystick_index)
19991999
} else {
20002000
type = SDL_GetGameControllerTypeFromString(type_string);
20012001
}
2002+
SDL_free(mapping);
20022003
return type;
20032004
}
2005+
SDL_free(mapping);
20042006
}
20052007
return SDL_GetJoystickGameControllerTypeFromGUID(joystick_guid, SDL_JoystickNameForIndex(joystick_index));
20062008
}

0 commit comments

Comments
 (0)