Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault with no gamepad plugged in #85

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions rott/rt_in.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int sdl_mouse_delta_x = 0;
static int sdl_mouse_delta_y = 0;
static unsigned short sdl_mouse_button_mask = 0;
static int sdl_total_sticks = 0;
static unsigned short *sdl_stick_button_state = NULL;
static unsigned short sdl_stick_button_state[MaxJoys];
static int sdl_mouse_grabbed = 0;
extern boolean sdl_fullscreen;

Expand Down Expand Up @@ -718,15 +718,6 @@ boolean INL_StartJoy (unsigned short joy)
SDL_Init(SDL_INIT_JOYSTICK);
sdl_total_sticks = SDL_NumJoysticks();
if (sdl_total_sticks > MaxJoys) sdl_total_sticks = MaxJoys;

if ((sdl_stick_button_state == NULL) && (sdl_total_sticks > 0))
{
sdl_stick_button_state = (unsigned short *) malloc(sizeof (unsigned short) * sdl_total_sticks);
if (sdl_stick_button_state == NULL)
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
else
memset(sdl_stick_button_state, '\0', sizeof (unsigned short) * sdl_total_sticks);
}
SDL_JoystickEventState(SDL_ENABLE);
}

Expand Down
Loading