Skip to content

fix(WiFi/ESP32): check cb_event for NULL before calling on station connect/disconnect#57

Open
94xhn wants to merge 1 commit into
ARM-software:mainfrom
94xhn:fix/wifi-esp32-cb-event-null-check
Open

fix(WiFi/ESP32): check cb_event for NULL before calling on station connect/disconnect#57
94xhn wants to merge 1 commit into
ARM-software:mainfrom
94xhn:fix/wifi-esp32-cb-event-null-check

Conversation

@94xhn

@94xhn 94xhn commented Jul 11, 2026

Copy link
Copy Markdown

Fixes #13.

ARM_WIFI_Initialize() accepts a cb_event callback that, per the driver's documented behavior, may be NULL if the caller doesn't need event callbacks. pCtrl->cb_event is also explicitly set to NULL on Uninitialize().

However AT_Notify() calls pCtrl->cb_event(...) unconditionally for AT_NOTIFY_STATION_CONNECTED and AT_NOTIFY_STATION_DISCONNECTED (which raise ARM_WIFI_EVENT_AP_CONNECT/ARM_WIFI_EVENT_AP_DISCONNECT respectively) - the only two call sites of cb_event in this function - with no NULL check. As the issue describes, this triggers whenever a station connects to or disconnects from the local AP (e.g. a remote host dropping its connection) while no event callback was registered, resulting in a null pointer call.

Fix: guard both call sites with if (pCtrl->cb_event != NULL), exactly as suggested in the issue and confirmed by @VladimirUmek's comment ("this check shall be added").

Test plan

No physical ESP32 hardware/AT-command host available to exercise this path end-to-end. Verified by code inspection: confirmed these are the only two cb_event invocations inside AT_Notify(), confirmed cb_event can legitimately be NULL per ARM_WIFI_Initialize()'s documented parameter contract and its Uninitialize() reset, and confirmed no other AT_NOTIFY_* branch in the same function calls cb_event (so no other call sites need the same guard).

Disclosure

Generative AI (Claude) was used to help investigate this and implement the fix. All changes were reviewed by me before submission.

…nnect/disconnect

ARM_WIFI_Initialize() accepts a NULL cb_event when the caller doesn't
need event callbacks, and this is documented as a valid usage. But
AT_Notify() calls pCtrl->cb_event() unconditionally for
AT_NOTIFY_STATION_CONNECTED/AT_NOTIFY_STATION_DISCONNECTED (which
raise ARM_WIFI_EVENT_AP_CONNECT/ARM_WIFI_EVENT_AP_DISCONNECT), with
no NULL check - a null pointer call if a station connects to or
disconnects from the local AP while no callback was registered.

Fixes ARM-software#13.

Signed-off-by: 94xhn <87560781+94xhn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ESP32 ARM_WIFI_Initialize callback parameter not checked for NULL

1 participant