Skip to content

Commit

Permalink
joystic: NPE fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bestander committed May 14, 2024
1 parent 1a1676e commit aacd26e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/duke3d/src/menus.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@ void Menu_PopulateNewGameCustomL3(int e, int s)


static void Menu_PopulateJoystick(void) static void Menu_PopulateJoystick(void)
{ {
for (int i = 0; i < joystick.numButtons + 4*joystick.numHats + 2*joystick.isGameController; ++i) for (int i = 0; i < joystick.numButtons + 4*joystick.numHats + joystick.isGameController; ++i)
{ {
if (i < joystick.numButtons) if (i < joystick.numButtons)
{ {
Expand All @@ -1884,7 +1884,7 @@ static void Menu_PopulateJoystick(void)
} }
else if (joystick.isGameController) else if (joystick.isGameController)
{ {
auto const name = joyGetName(0, i - joystick.numButtons + 4); auto const name = joyGetName(0, i - joystick.numButtons + 4*joystick.numHats);
Bassert(name != nullptr); Bassert(name != nullptr);
Bstrncpy(MenuJoystickNames[i], name, MAXJOYBUTTONSTRINGLENGTH); Bstrncpy(MenuJoystickNames[i], name, MAXJOYBUTTONSTRINGLENGTH);
} }
Expand Down

0 comments on commit aacd26e

Please sign in to comment.