From 24fae67788cf798ed3916fc6dc6ee01822bb8100 Mon Sep 17 00:00:00 2001 From: Stephen Ostermiller Date: Sat, 28 Jun 2025 05:46:41 -0400 Subject: [PATCH] Add null check --- docs/ChangeLog/20250831/pr25415.md | 2 +- docs/features/tap_dance.md | 2 +- tests/tap_dance/examples.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/ChangeLog/20250831/pr25415.md b/docs/ChangeLog/20250831/pr25415.md index e2cac6cc8ca..ffa29e2ec4b 100644 --- a/docs/ChangeLog/20250831/pr25415.md +++ b/docs/ChangeLog/20250831/pr25415.md @@ -1,3 +1,3 @@ # Tap dance state removed from `tap_dance_action_t` -Code that accessed the tap dance state as a field in the tap dance action should now call `tap_dance_get_state(int tap_dance_idx)` instead. +Code that accessed the tap dance state as a field in the tap dance action should now call `tap_dance_get_state(int tap_dance_idx)` instead. That function may return `NULL` if many tap dance keys are held together. Add a `NULL` check before using the returned state. diff --git a/docs/features/tap_dance.md b/docs/features/tap_dance.md index 8f6887c96e4..f0e5ddb1742 100644 --- a/docs/features/tap_dance.md +++ b/docs/features/tap_dance.md @@ -215,7 +215,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case TD(CT_CLN): action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(keycode)); state = tap_dance_get_state(QK_TAP_DANCE_GET_INDEX(keycode)); - if (!record->event.pressed && state->count && !state->finished) { + if (!record->event.pressed && state != NULL && state->count && !state->finished) { tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; tap_code16(tap_hold->tap); } diff --git a/tests/tap_dance/examples.c b/tests/tap_dance/examples.c index 1d28ba24d90..6aaf0082323 100644 --- a/tests/tap_dance/examples.c +++ b/tests/tap_dance/examples.c @@ -87,7 +87,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case TD(CT_CLN): action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(keycode)); state = tap_dance_get_state(QK_TAP_DANCE_GET_INDEX(keycode)); - if (!record->event.pressed && state->count && !state->finished) { + if (!record->event.pressed && state != NULL && state->count && !state->finished) { tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; tap_code16(tap_hold->tap); }