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
This commit is contained in:
Aleksander Morgado
2021-05-12 22:12:46 +02:00
parent f916d075a7
commit bb928dbf74
+1 -1
View File
@@ -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,