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 <aleksandermj@google.com>
This commit is contained in:
Aleksander Morgado
2026-07-10 15:00:07 +02:00
committed by Aleksander Morgado
parent c3e7ffaae0
commit db72a182c1
+1 -1
View File
@@ -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);
}