Unverified Commit f4d8a481 authored by Juan Luis Leal Contreras's avatar Juan Luis Leal Contreras Committed by GitHub

Fixed #7406 crash on WiFi STA_DISCONNECTED event with reason 0 (#7414)

Fixed #7406 . The "reason2str" macro in WiFiGeneric.cpp tries to read memory from index "-1"  in "system_event_reasons" array when handling STA_DISCONNECTED event with reason 0. Dealing with reason 0 as a reason 1 (WIFI_REASON_UNSPECIFIED) will solve the problem (the reason for this event to arrive with reason 0 is unknown). #7406
parent 2cebee4a
......@@ -947,6 +947,9 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
//esp_netif_create_ip6_linklocal(esp_netifs[ESP_IF_WIFI_STA]);
} else if(event->event_id == ARDUINO_EVENT_WIFI_STA_DISCONNECTED) {
uint8_t reason = event->event_info.wifi_sta_disconnected.reason;
// Reason 0 causes crash, use reason 1 (UNSPECIFIED) instead
if(!reason)
reason = WIFI_REASON_UNSPECIFIED;
log_w("Reason: %u - %s", reason, reason2str(reason));
if(reason == WIFI_REASON_NO_AP_FOUND) {
WiFiSTAClass::_setStatus(WL_NO_SSID_AVAIL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment