Skip to content
Snippets Groups Projects
Commit 84381fa0 authored by Damien George's avatar Damien George
Browse files

esp8266/modnetwork: Protect scan() callback against memory errors.

scan() allocates memory so may cause an exception to be raised.
parent 55df14f1
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment