From 8ee8c1d00da2ea77eebac4e501b4f3139ce71fcf Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Fri, 24 Jan 2025 11:12:46 -0500 Subject: [PATCH] fix(events): Add NULL check for `as_##event_type`. See #2792 where this cause segfault. --- app/include/zmk/event_manager.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/include/zmk/event_manager.h b/app/include/zmk/event_manager.h index 0eb63ad73d5..615af60a65c 100644 --- a/app/include/zmk/event_manager.h +++ b/app/include/zmk/event_manager.h @@ -57,6 +57,9 @@ struct zmk_event_subscription { return ZMK_EVENT_RAISE(ev); \ }; \ struct event_type *as_##event_type(const zmk_event_t *eh) { \ + if (eh == NULL) { \ + return NULL; \ + } \ return (eh->event == &zmk_event_##event_type) ? &((struct event_type##_event *)eh)->data \ : NULL; \ };