Fix for the previous commit (we should leave one character at the end for the \0 terminator)

This commit is contained in:
Dimitris Panokostas 2017-09-21 17:58:14 +02:00
parent 5042b7bae4
commit 46a85cd1fb

View file

@ -296,7 +296,7 @@ static int init_joystick(void)
for (int cpt; cpt < nr_joysticks; cpt++)
{
Joysticktable[cpt] = SDL_JoystickOpen(cpt);
strncpy(JoystickName[cpt], SDL_JoystickName(cpt), sizeof JoystickName[cpt]);
strncpy(JoystickName[cpt], SDL_JoystickName(cpt), sizeof JoystickName[cpt] - 1);
printf("Joystick %i : %s\n", cpt, JoystickName[cpt]);
printf(" Buttons: %i Axis: %i Hats: %i\n", SDL_JoystickNumButtons(Joysticktable[cpt]), SDL_JoystickNumAxes(Joysticktable[cpt]), SDL_JoystickNumHats(Joysticktable[cpt]));