mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 20:28:49 -05:00
Fix crash when joystick name unavailable on OS X
Fixes #694. Closes #701.
This commit is contained in:
parent
d6e0a4390c
commit
49d228207f
|
@ -88,6 +88,7 @@ used by the tests and examples and are not required to build the library.
|
||||||
when no windows existed
|
when no windows existed
|
||||||
- [Cocoa] Removed support for OS X 10.6
|
- [Cocoa] Removed support for OS X 10.6
|
||||||
- [Cocoa] Bugfix: Full screen windows on secondary monitors were mispositioned
|
- [Cocoa] Bugfix: Full screen windows on secondary monitors were mispositioned
|
||||||
|
- [Cocoa] Bugfix: Connecting a joystick that reports no name would segfault
|
||||||
- [X11] Bugfix: Monitor connection and disconnection events were not reported
|
- [X11] Bugfix: Monitor connection and disconnection events were not reported
|
||||||
- [X11] Bugfix: Decoding of UTF-8 text from XIM could continue past the end
|
- [X11] Bugfix: Decoding of UTF-8 text from XIM could continue past the end
|
||||||
- [X11] Bugfix: An XKB structure was leaked during `glfwInit`
|
- [X11] Bugfix: An XKB structure was leaked during `glfwInit`
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#include <mach/mach_error.h>
|
#include <mach/mach_error.h>
|
||||||
|
@ -287,10 +288,15 @@ static void matchCallback(void* context,
|
||||||
|
|
||||||
CFStringRef name = IOHIDDeviceGetProperty(deviceRef,
|
CFStringRef name = IOHIDDeviceGetProperty(deviceRef,
|
||||||
CFSTR(kIOHIDProductKey));
|
CFSTR(kIOHIDProductKey));
|
||||||
CFStringGetCString(name,
|
if (name)
|
||||||
joystick->name,
|
{
|
||||||
sizeof(joystick->name),
|
CFStringGetCString(name,
|
||||||
kCFStringEncodingUTF8);
|
joystick->name,
|
||||||
|
sizeof(joystick->name),
|
||||||
|
kCFStringEncodingUTF8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strncpy(joystick->name, "Unknown", sizeof(joystick->name));
|
||||||
|
|
||||||
joystick->axisElements = CFArrayCreateMutable(NULL, 0, NULL);
|
joystick->axisElements = CFArrayCreateMutable(NULL, 0, NULL);
|
||||||
joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL);
|
joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user