Skip to content

Commit 116eeee

Browse files
committed
esp8266/esp_mphal: Fix NLR buffer leak in call_dupterm_read().
1 parent bc2ba6b commit 116eeee

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

esp8266/esp_mphal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,16 @@ static int call_dupterm_read(void) {
166166
read_m[2] = MP_OBJ_NEW_SMALL_INT(1);
167167
mp_obj_t res = mp_call_method_n_kw(1, 0, read_m);
168168
if (res == mp_const_none) {
169+
nlr_pop();
169170
return -2;
170171
}
171172
mp_buffer_info_t bufinfo;
172173
mp_get_buffer_raise(res, &bufinfo, MP_BUFFER_READ);
174+
nlr_pop();
173175
if (bufinfo.len == 0) {
174176
mp_uos_deactivate("dupterm: EOF received, deactivating\n", MP_OBJ_NULL);
175177
return -1;
176178
}
177-
nlr_pop();
178179
return *(byte*)bufinfo.buf;
179180
} else {
180181
mp_uos_deactivate("dupterm: Exception in read() method, deactivating: ", nlr.ret_val);

0 commit comments

Comments
 (0)