Skip to content

Commit

Permalink
Merge pull request #3868 from libretro/master
Browse files Browse the repository at this point in the history
Prevent more potential crashes
  • Loading branch information
inactive123 committed Oct 26, 2016
2 parents 2bcbe01 + 5fc6519 commit d1c04ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions input/drivers/linuxraw_input.c
Expand Up @@ -142,7 +142,7 @@ static int16_t linuxraw_input_state(void *data,
const struct retro_keybind **binds, unsigned port,
unsigned device, unsigned idx, unsigned id)
{
int16_t ret;
int16_t ret = 0;
linuxraw_input_t *linuxraw = (linuxraw_input_t*)data;

switch (device)
Expand All @@ -153,7 +153,8 @@ static int16_t linuxraw_input_state(void *data,
input_joypad_pressed(linuxraw->joypad, port, binds[port], id);
break;
case RETRO_DEVICE_ANALOG:
ret = linuxraw_analog_pressed(linuxraw, binds[port], idx, id);
if (binds[port])
ret = linuxraw_analog_pressed(linuxraw, binds[port], idx, id);
if (!ret && binds[port])
ret = input_joypad_analog(linuxraw->joypad, port, idx, id, binds[port]);
return ret;
Expand Down
6 changes: 4 additions & 2 deletions input/drivers/sdl_input.c
Expand Up @@ -165,7 +165,7 @@ static int16_t sdl_joypad_device_state(sdl_input_t *sdl, const struct retro_keyb
static int16_t sdl_analog_device_state(sdl_input_t *sdl, const struct retro_keybind **binds,
unsigned port_num, unsigned idx, unsigned id)
{
int16_t ret = sdl_analog_pressed(sdl, binds[port_num], idx, id);
int16_t ret = binds[port_num] ? sdl_analog_pressed(sdl, binds[port_num], idx, id) : 0;
if (!ret && binds[port_num])
ret = input_joypad_analog(sdl->joypad, port_num, idx, id, binds[port_num]);
return ret;
Expand Down Expand Up @@ -272,7 +272,9 @@ static int16_t sdl_input_state(void *data_, const struct retro_keybind **binds,
case RETRO_DEVICE_JOYPAD:
return sdl_joypad_device_state(data, binds, port, id, &type);
case RETRO_DEVICE_ANALOG:
return sdl_analog_device_state(data, binds, port, idx, id);
{
return sdl_analog_device_state(data, binds, port, idx, id);
}
case RETRO_DEVICE_MOUSE:
return sdl_mouse_device_state(data, id);
case RETRO_DEVICE_POINTER:
Expand Down
5 changes: 3 additions & 2 deletions input/drivers/x11_input.c
Expand Up @@ -251,7 +251,7 @@ static int16_t x_input_state(void *data,
const struct retro_keybind **binds, unsigned port,
unsigned device, unsigned idx, unsigned id)
{
int16_t ret;
int16_t ret = 0;
x11_input_t *x11 = (x11_input_t*)data;

switch (device)
Expand All @@ -264,7 +264,8 @@ static int16_t x_input_state(void *data,
case RETRO_DEVICE_KEYBOARD:
return x_key_pressed(x11, id);
case RETRO_DEVICE_ANALOG:
ret = x_pressed_analog(x11, binds[port], idx, id);
if (binds[port])
ret = x_pressed_analog(x11, binds[port], idx, id);
if (!ret && binds[port] && binds[port])
ret = input_joypad_analog(x11->joypad, port, idx,
id, binds[port]);
Expand Down

0 comments on commit d1c04ad

Please sign in to comment.