esp8266/modnetwork: Protect scan() callback against memory errors.
scan() allocates memory so may cause an exception to be raised.
This commit is contained in:
parent
55df14f1a4
commit
84381fa0fc
@ -136,6 +136,9 @@ STATIC void esp_scan_cb(scaninfo *si, STATUS status) {
|
||||
return;
|
||||
}
|
||||
if (si->pbss && status == 0) {
|
||||
// we need to catch any memory errors
|
||||
nlr_buf_t nlr;
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
struct bss_info *bs;
|
||||
STAILQ_FOREACH(bs, si->pbss, next) {
|
||||
mp_obj_tuple_t *t = mp_obj_new_tuple(6, NULL);
|
||||
@ -147,6 +150,12 @@ STATIC void esp_scan_cb(scaninfo *si, STATUS status) {
|
||||
t->items[5] = MP_OBJ_NEW_SMALL_INT(bs->is_hidden);
|
||||
mp_obj_list_append(*esp_scan_list, MP_OBJ_FROM_PTR(t));
|
||||
}
|
||||
nlr_pop();
|
||||
} else {
|
||||
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
|
||||
// indicate error
|
||||
*esp_scan_list = MP_OBJ_NULL;
|
||||
}
|
||||
} else {
|
||||
// indicate error
|
||||
*esp_scan_list = MP_OBJ_NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user