Skip to content

Commit

Permalink
fix(events): Add NULL check for as_##event_type.
Browse files Browse the repository at this point in the history
See zmkfirmware#2792 where this cause segfault.
  • Loading branch information
mlouielu committed Jan 24, 2025
1 parent 4f72e7c commit 8ee8c1d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/include/zmk/event_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
};
Expand Down

0 comments on commit 8ee8c1d

Please sign in to comment.