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:
committed by
Aleksander Morgado
parent
c3e7ffaae0
commit
db72a182c1
@@ -241,7 +241,7 @@ parse_unsolicited (MMPortSerial *port, GByteArray *response)
|
|||||||
response->len,
|
response->len,
|
||||||
0, 0, &match_info, NULL);
|
0, 0, &match_info, NULL);
|
||||||
if (handler->callback) {
|
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);
|
handler->callback (self, match_info, handler->user_data);
|
||||||
g_match_info_next (match_info, NULL);
|
g_match_info_next (match_info, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user