From 3b8332a5a8489393d8d71562f932275b7d4f0bbb Mon Sep 17 00:00:00 2001 From: Lukas Voegl Date: Fri, 25 Jul 2025 15:38:34 +0200 Subject: [PATCH 1/2] cli: free ignored ports Signed-off-by: Lukas Voegl --- cli/mmcli-modem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli/mmcli-modem.c b/cli/mmcli-modem.c index 45739625..346f6a30 100644 --- a/cli/mmcli-modem.c +++ b/cli/mmcli-modem.c @@ -346,9 +346,11 @@ print_modem_info (void) g_free (bands); mm_modem_get_ports (ctx->modem, &ports, &n_ports); ports_string = mm_common_build_ports_string (ports, n_ports); + mm_modem_port_info_array_free (ports, n_ports); mm_modem_get_ignored_ports (ctx->modem, &ignored_ports, &n_ignored_ports); ignored_ports_string = mm_common_build_ports_string (ignored_ports, n_ignored_ports); - mm_modem_port_info_array_free (ports, n_ports); + if (ignored_ports) + mm_modem_port_info_array_free (ignored_ports, n_ignored_ports); if (mm_modem_get_current_modes (ctx->modem, &allowed_modes, &preferred_mode)) { allowed_modes_string = mm_modem_mode_build_string_from_mask (allowed_modes); preferred_mode_string = mm_modem_mode_build_string_from_mask (preferred_mode); From e8a5ba04d042e4a822d5fad56465fda91704ccf4 Mon Sep 17 00:00:00 2001 From: Lukas Voegl Date: Fri, 1 Aug 2025 11:05:27 +0200 Subject: [PATCH 2/2] cli: free ports only if not `NULL` Signed-off-by: Lukas Voegl --- cli/mmcli-modem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/mmcli-modem.c b/cli/mmcli-modem.c index 346f6a30..9d3d900a 100644 --- a/cli/mmcli-modem.c +++ b/cli/mmcli-modem.c @@ -346,7 +346,8 @@ print_modem_info (void) g_free (bands); mm_modem_get_ports (ctx->modem, &ports, &n_ports); ports_string = mm_common_build_ports_string (ports, n_ports); - mm_modem_port_info_array_free (ports, n_ports); + if (ports) + mm_modem_port_info_array_free (ports, n_ports); mm_modem_get_ignored_ports (ctx->modem, &ignored_ports, &n_ignored_ports); ignored_ports_string = mm_common_build_ports_string (ignored_ports, n_ignored_ports); if (ignored_ports)