@@ -1290,6 +1290,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
1290
1290
value_caps = SDL_stack_alloc (HIDP_VALUE_CAPS , caps .NumberInputValueCaps );
1291
1291
if (SDL_HidP_GetValueCaps (HidP_Input , value_caps , & caps .NumberInputValueCaps , ctx -> preparsed_data ) != HIDP_STATUS_SUCCESS ) {
1292
1292
RAWINPUT_JoystickClose (joystick );
1293
+ SDL_stack_free (button_caps );
1293
1294
return SDL_SetError ("Couldn't get device value capabilities" );
1294
1295
}
1295
1296
@@ -1318,6 +1319,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
1318
1319
ctx -> button_indices = (USHORT * )SDL_malloc (joystick -> nbuttons * sizeof (* ctx -> button_indices ));
1319
1320
if (!ctx -> button_indices ) {
1320
1321
RAWINPUT_JoystickClose (joystick );
1322
+ SDL_stack_free (value_caps );
1323
+ SDL_stack_free (button_caps );
1321
1324
return SDL_OutOfMemory ();
1322
1325
}
1323
1326
@@ -1342,6 +1345,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
1342
1345
joystick -> nbuttons += 1 ;
1343
1346
}
1344
1347
1348
+ SDL_stack_free (button_caps );
1349
+
1345
1350
for (i = 0 ; i < caps .NumberInputValueCaps ; ++ i ) {
1346
1351
HIDP_VALUE_CAPS * cap = & value_caps [i ];
1347
1352
@@ -1371,6 +1376,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
1371
1376
ctx -> axis_indices = (USHORT * )SDL_malloc (joystick -> naxes * sizeof (* ctx -> axis_indices ));
1372
1377
if (!ctx -> axis_indices ) {
1373
1378
RAWINPUT_JoystickClose (joystick );
1379
+ SDL_stack_free (value_caps );
1374
1380
return SDL_OutOfMemory ();
1375
1381
}
1376
1382
@@ -1404,6 +1410,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
1404
1410
ctx -> hat_indices = (USHORT * )SDL_malloc (joystick -> nhats * sizeof (* ctx -> hat_indices ));
1405
1411
if (!ctx -> hat_indices ) {
1406
1412
RAWINPUT_JoystickClose (joystick );
1413
+ SDL_stack_free (value_caps );
1407
1414
return SDL_OutOfMemory ();
1408
1415
}
1409
1416
@@ -1422,6 +1429,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
1422
1429
}
1423
1430
}
1424
1431
1432
+ SDL_stack_free (value_caps );
1433
+
1425
1434
joystick -> epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN ;
1426
1435
1427
1436
return 0 ;
0 commit comments