From 0bb1ce741dad346d98e041986fa786a75c6c4836 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 18 Sep 2018 13:07:43 +0200 Subject: HeadphoneKey(runAction): Fix EXC_BAD_ACCESS on undefined map If no map was defined for a headphone button, the fields in the `CKeyActionResult` `result` would be null pointers, causing the bad access exception. Before doing anything, check that the pointer points to something real. Also, fix the `kind` check to use the `ActionKind_Map` enum now that the `dome-key-map` library has been updated with the new definition of `CKeyActionResult`. --- DomeKey/HeadphoneKey.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m index 8144035..b6d783e 100644 --- a/DomeKey/HeadphoneKey.m +++ b/DomeKey/HeadphoneKey.m @@ -81,7 +81,8 @@ const CKeyActionResult *result = c_run_key_action(trigger, NULL); - if (*result->kind == MapKind_Map) { + if (result->kind && + *result->kind == ActionKind_Map) { const char *c = result->action; int i = 0; while (*c) { -- cgit v1.2.3