From bb928dbf7409b445e6aaab994c571fb7d504a8d7 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 12 May 2021 22:11:50 +0200 Subject: [PATCH] iface-modem: fix segfault if attempting to switch slot and slots unsupported Reported and fix suggested by Maxim Anisimov Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/368 --- src/mm-iface-modem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 2068dda9..245abe4c 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -1126,7 +1126,7 @@ handle_set_primary_sim_slot_auth_ready (MMBaseModem *self, /* Validate SIM slot number */ sim_slot_paths = mm_gdbus_modem_get_sim_slots (ctx->skeleton); - if (ctx->requested_sim_slot > g_strv_length ((gchar **)sim_slot_paths)) { + if (!sim_slot_paths || (ctx->requested_sim_slot > g_strv_length ((gchar **)sim_slot_paths))) { g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS,