esp8266/modnetwork: Raise ValueError when getting invalid WLAN id.

Instead of crashing due to out-of-bounds array access.  Fixes #3348.
This commit is contained in:
Damien George 2018-05-17 22:12:24 +10:00
parent f8a5cd24d8
commit dd13065843

View File

@ -65,6 +65,9 @@ STATIC mp_obj_t get_wlan(size_t n_args, const mp_obj_t *args) {
int idx = 0;
if (n_args > 0) {
idx = mp_obj_get_int(args[0]);
if (idx < 0 || idx >= sizeof(wlan_objs)) {
mp_raise_ValueError(NULL);
}
}
return MP_OBJ_FROM_PTR(&wlan_objs[idx]);
}