From db72a182c108c91796ee10d323559309b1a06ef5 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Thu, 2 Jul 2026 17:53:40 +0000 Subject: [PATCH] port-serial-at: fix crash if URC handler is cleared mid-dispatch Update parse_unsolicited() to re-check handler->callback on each iteration of the match dispatch loop. If a URC handler callback clears itself during dispatch (e.g. to stop listening), subsequent matches in the same buffer would attempt to call the NULL pointer, causing a crash. https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1074 Signed-off-by: Aleksander Morgado --- src/mm-port-serial-at.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mm-port-serial-at.c b/src/mm-port-serial-at.c index ca2cc540..267ebdd5 100644 --- a/src/mm-port-serial-at.c +++ b/src/mm-port-serial-at.c @@ -241,7 +241,7 @@ parse_unsolicited (MMPortSerial *port, GByteArray *response) response->len, 0, 0, &match_info, NULL); if (handler->callback) { - while (g_match_info_matches (match_info)) { + while (g_match_info_matches (match_info) && handler->callback) { handler->callback (self, match_info, handler->user_data); g_match_info_next (match_info, NULL); }