mirror of https://github.com/libsdl-org/SDL.git
Update SDL_hidapi_switch.c
Assign NULL to pLeftStickCal and pRightStickCal pointer, and check for NULL-ness before proceeding otherwise return false as a safety check.
This commit is contained in:
parent
ff9c4b2a70
commit
a26f8fbd6c
|
|
@ -928,8 +928,8 @@ static bool SetIMUEnabled(SDL_DriverSwitch_Context *ctx, bool enabled)
|
||||||
|
|
||||||
static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
|
static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
|
||||||
{
|
{
|
||||||
Uint8 *pLeftStickCal;
|
Uint8 *pLeftStickCal = NULL;
|
||||||
Uint8 *pRightStickCal;
|
Uint8 *pRightStickCal = NULL;
|
||||||
size_t stick, axis;
|
size_t stick, axis;
|
||||||
SwitchSubcommandInputPacket_t *user_reply = NULL;
|
SwitchSubcommandInputPacket_t *user_reply = NULL;
|
||||||
SwitchSubcommandInputPacket_t *factory_reply = NULL;
|
SwitchSubcommandInputPacket_t *factory_reply = NULL;
|
||||||
|
|
@ -984,6 +984,12 @@ static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we still don't have calibration data, return false
|
||||||
|
if (pLeftStickCal == NULL || pRightStickCal == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Stick calibration values are 12-bits each and are packed by bit
|
/* Stick calibration values are 12-bits each and are packed by bit
|
||||||
* For whatever reason the fields are in a different order for each stick
|
* For whatever reason the fields are in a different order for each stick
|
||||||
* Left: X-Max, Y-Max, X-Center, Y-Center, X-Min, Y-Min
|
* Left: X-Max, Y-Max, X-Center, Y-Center, X-Min, Y-Min
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue