Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 9725a65

Browse files
committed
extmod/uos_dupterm: Swallow any errors from dupterm closing the stream.
Without this the board will crash when deactivating a stream that doesn't have a close() method (eg UART) or that raises an exception within the method (eg user-defined function).
1 parent c53ca32 commit 9725a65

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

extmod/uos_dupterm.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ void mp_uos_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc) {
4343
if (exc != MP_OBJ_NULL) {
4444
mp_obj_print_exception(&mp_plat_print, exc);
4545
}
46-
mp_stream_close(term);
46+
nlr_buf_t nlr;
47+
if (nlr_push(&nlr) == 0) {
48+
mp_stream_close(term);
49+
nlr_pop();
50+
} else {
51+
// Ignore any errors during stream closing
52+
}
4753
}
4854

4955
int mp_uos_dupterm_rx_chr(void) {
@@ -61,8 +67,8 @@ int mp_uos_dupterm_rx_chr(void) {
6167
if (res == mp_const_none) {
6268
nlr_pop();
6369
} else if (res == MP_OBJ_NEW_SMALL_INT(0)) {
64-
mp_uos_deactivate(idx, "dupterm: EOF received, deactivating\n", MP_OBJ_NULL);
6570
nlr_pop();
71+
mp_uos_deactivate(idx, "dupterm: EOF received, deactivating\n", MP_OBJ_NULL);
6672
} else {
6773
mp_buffer_info_t bufinfo;
6874
mp_get_buffer_raise(MP_STATE_VM(dupterm_arr_obj), &bufinfo, MP_BUFFER_READ);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy