esp8266/modnetwork: Return empty str for hostname if STA is inactive.

Instead of crashing due to NULL pointer dereference.  Fixes issue #3341.
pull/3791/head
Damien George 2018-05-17 22:11:22 +10:00
rodzic 94a79f340d
commit f8a5cd24d8
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -443,7 +443,11 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
case MP_QSTR_dhcp_hostname: {
req_if = STATION_IF;
char* s = wifi_station_get_hostname();
val = mp_obj_new_str(s, strlen(s));
if (s == NULL) {
val = MP_OBJ_NEW_QSTR(MP_QSTR_);
} else {
val = mp_obj_new_str(s, strlen(s));
}
break;
}
default: