From d4d7e2515ffbd34bf32f6a56bd5c69aa38f0a507 Mon Sep 17 00:00:00 2001 From: DimitriPilot3 Date: Wed, 15 Jun 2011 12:50:47 +0000 Subject: [PATCH] Apply the simple NULL-checking patch from issue 4311. Judging by the feedback provided by other OSX users, this appears to fix the crash when starting Dolphin on OSX with devices that have an empty name. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7598 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/InputCommon/Src/ControllerInterface/OSX/OSX.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSX.mm b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSX.mm index 5c5143fdb2..bf4f49bac6 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSX.mm +++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSX.mm @@ -137,8 +137,9 @@ static void DeviceMatching_callback(void* inContext, void *inSender, IOHIDDeviceRef inIOHIDDeviceRef) { - std::string name = [(NSString *)IOHIDDeviceGetProperty(inIOHIDDeviceRef, - CFSTR(kIOHIDProductKey)) UTF8String]; + NSString *pName = (NSString *) + IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDProductKey)); + std::string name = (pName != NULL) ? [pName UTF8String] : "Unknown device"; DeviceDebugPrint(inIOHIDDeviceRef); @@ -154,7 +155,7 @@ static void DeviceMatching_callback(void* inContext, else if (IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse)) devices->push_back(new Mouse(inIOHIDDeviceRef, - name, mouse_name_counts[name++])); + name, mouse_name_counts[name]++)); #endif else devices->push_back(new Joystick(inIOHIDDeviceRef,