|
@@ -1290,6 +1290,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
|
|
value_caps = SDL_stack_alloc(HIDP_VALUE_CAPS, caps.NumberInputValueCaps);
|
|
|
if (SDL_HidP_GetValueCaps(HidP_Input, value_caps, &caps.NumberInputValueCaps, ctx->preparsed_data) != HIDP_STATUS_SUCCESS) {
|
|
|
RAWINPUT_JoystickClose(joystick);
|
|
|
+ SDL_stack_free(button_caps);
|
|
|
return SDL_SetError("Couldn't get device value capabilities");
|
|
|
}
|
|
|
|
|
@@ -1318,6 +1319,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
|
|
ctx->button_indices = (USHORT *)SDL_malloc(joystick->nbuttons * sizeof(*ctx->button_indices));
|
|
|
if (!ctx->button_indices) {
|
|
|
RAWINPUT_JoystickClose(joystick);
|
|
|
+ SDL_stack_free(value_caps);
|
|
|
+ SDL_stack_free(button_caps);
|
|
|
return SDL_OutOfMemory();
|
|
|
}
|
|
|
|
|
@@ -1342,6 +1345,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
|
|
joystick->nbuttons += 1;
|
|
|
}
|
|
|
|
|
|
+ SDL_stack_free(button_caps);
|
|
|
+
|
|
|
for (i = 0; i < caps.NumberInputValueCaps; ++i) {
|
|
|
HIDP_VALUE_CAPS *cap = &value_caps[i];
|
|
|
|
|
@@ -1371,6 +1376,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
|
|
ctx->axis_indices = (USHORT *)SDL_malloc(joystick->naxes * sizeof(*ctx->axis_indices));
|
|
|
if (!ctx->axis_indices) {
|
|
|
RAWINPUT_JoystickClose(joystick);
|
|
|
+ SDL_stack_free(value_caps);
|
|
|
return SDL_OutOfMemory();
|
|
|
}
|
|
|
|
|
@@ -1404,6 +1410,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
|
|
ctx->hat_indices = (USHORT *)SDL_malloc(joystick->nhats * sizeof(*ctx->hat_indices));
|
|
|
if (!ctx->hat_indices) {
|
|
|
RAWINPUT_JoystickClose(joystick);
|
|
|
+ SDL_stack_free(value_caps);
|
|
|
return SDL_OutOfMemory();
|
|
|
}
|
|
|
|
|
@@ -1422,6 +1429,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ SDL_stack_free(value_caps);
|
|
|
+
|
|
|
joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
|
|
|
|
|
|
return 0;
|