In case last hatswitch does not match cookie

For the mayflash N64 adapter, I was getting a BAD EXC ADDRESS (in mac OS 10.13) for this line (tmp was NULL). Retroarch would crash in the gui if I pressed a button from the DPAD on controller 2. With this change, it no longer crashes in the gui and still registers the button push.
This commit is contained in:
A Schain 2020-04-30 13:27:44 -04:00 committed by GitHub
parent 9c100ded3a
commit 1e751d00ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -290,7 +290,7 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
while (tmp && tmp->cookie != (IOHIDElementCookie)cookie)
tmp = tmp->next;
if (tmp->cookie == (IOHIDElementCookie)cookie)
if (tmp && tmp->cookie == (IOHIDElementCookie)cookie)
{
CFIndex min = IOHIDElementGetLogicalMin(element);
CFIndex range = IOHIDElementGetLogicalMax(element) - min;