Skip to content

Commit 4eac44b

Browse files
committed
RAWINPUT_JoystickOpen: add missing SDL_stack_free() calls.
Fixes #10574. (cherry picked from commit 8452123)
1 parent 1b8d563 commit 4eac44b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/joystick/windows/SDL_rawinputjoystick.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
12901290
value_caps = SDL_stack_alloc(HIDP_VALUE_CAPS, caps.NumberInputValueCaps);
12911291
if (SDL_HidP_GetValueCaps(HidP_Input, value_caps, &caps.NumberInputValueCaps, ctx->preparsed_data) != HIDP_STATUS_SUCCESS) {
12921292
RAWINPUT_JoystickClose(joystick);
1293+
SDL_stack_free(button_caps);
12931294
return SDL_SetError("Couldn't get device value capabilities");
12941295
}
12951296

@@ -1318,6 +1319,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
13181319
ctx->button_indices = (USHORT *)SDL_malloc(joystick->nbuttons * sizeof(*ctx->button_indices));
13191320
if (!ctx->button_indices) {
13201321
RAWINPUT_JoystickClose(joystick);
1322+
SDL_stack_free(value_caps);
1323+
SDL_stack_free(button_caps);
13211324
return SDL_OutOfMemory();
13221325
}
13231326

@@ -1342,6 +1345,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
13421345
joystick->nbuttons += 1;
13431346
}
13441347

1348+
SDL_stack_free(button_caps);
1349+
13451350
for (i = 0; i < caps.NumberInputValueCaps; ++i) {
13461351
HIDP_VALUE_CAPS *cap = &value_caps[i];
13471352

@@ -1371,6 +1376,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
13711376
ctx->axis_indices = (USHORT *)SDL_malloc(joystick->naxes * sizeof(*ctx->axis_indices));
13721377
if (!ctx->axis_indices) {
13731378
RAWINPUT_JoystickClose(joystick);
1379+
SDL_stack_free(value_caps);
13741380
return SDL_OutOfMemory();
13751381
}
13761382

@@ -1404,6 +1410,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
14041410
ctx->hat_indices = (USHORT *)SDL_malloc(joystick->nhats * sizeof(*ctx->hat_indices));
14051411
if (!ctx->hat_indices) {
14061412
RAWINPUT_JoystickClose(joystick);
1413+
SDL_stack_free(value_caps);
14071414
return SDL_OutOfMemory();
14081415
}
14091416

@@ -1422,6 +1429,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
14221429
}
14231430
}
14241431

1432+
SDL_stack_free(value_caps);
1433+
14251434
joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
14261435

14271436
return 0;

0 commit comments

Comments
 (0)