From f79ed1ab447361dd7740db991d97224653ae5c21 Mon Sep 17 00:00:00 2001 From: Thad House Date: Wed, 13 Jan 2016 21:35:51 -0800 Subject: [PATCH] Artf4800: Fixes HALGetJoystick*** Segfault The HALGetJoystick*** methods were not initializing the descriptor variable properly. This was causing a SegFault if joysticks were moved around while one of these methods were running. Change-Id: If804c7ea724b10381765068e4d6fad75fad69ecb --- hal/lib/Shared/HAL.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hal/lib/Shared/HAL.cpp b/hal/lib/Shared/HAL.cpp index d77c6e7df2..0549259430 100644 --- a/hal/lib/Shared/HAL.cpp +++ b/hal/lib/Shared/HAL.cpp @@ -44,6 +44,9 @@ int HALGetJoystickDescriptor(uint8_t joystickNum, HALJoystickDescriptor *desc) int HALGetJoystickIsXbox(uint8_t joystickNum) { HALJoystickDescriptor joystickDesc; + joystickDesc.isXbox = 0; + joystickDesc.type = -1; + joystickDesc.name[0] = '\0'; if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0) { return 0; @@ -56,6 +59,9 @@ int HALGetJoystickIsXbox(uint8_t joystickNum) int HALGetJoystickType(uint8_t joystickNum) { HALJoystickDescriptor joystickDesc; + joystickDesc.isXbox = 0; + joystickDesc.type = -1; + joystickDesc.name[0] = '\0'; if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0) { return -1; @@ -68,6 +74,9 @@ int HALGetJoystickType(uint8_t joystickNum) char* HALGetJoystickName(uint8_t joystickNum) { HALJoystickDescriptor joystickDesc; + joystickDesc.isXbox = 0; + joystickDesc.type = -1; + joystickDesc.name[0] = '\0'; if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0) { char* name = (char*)std::malloc(1); @@ -85,6 +94,9 @@ char* HALGetJoystickName(uint8_t joystickNum) int HALGetJoystickAxisType(uint8_t joystickNum, uint8_t axis) { HALJoystickDescriptor joystickDesc; + joystickDesc.isXbox = 0; + joystickDesc.type = -1; + joystickDesc.name[0] = '\0'; if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0) { return -1;