From a97b58ebf742c3bae4fab73d66f35c959ddc0639 Mon Sep 17 00:00:00 2001 From: Louis-Alexis Eyraud Date: Tue, 9 Aug 2022 14:53:34 +0200 Subject: libmm-glib,profile-manager: fix memory leaks when listing connection profiles This commit fixes memory leaks that occur when invoking mm_modem_3gpp_profile_manager_list function. When processing the connection profile data retrieved from dbus in build_list_results function, the iterator data (of GVariant type) were not properly freed after use in the while loop. ==7903== 2,697 (144 direct, 2,553 indirect) bytes in 3 blocks are definitely lost in loss record 2,525 of 2,538 ==7903== at 0x484086F: malloc (vg_replace_malloc.c:381) ==7903== by 0x4A13938: g_malloc (gmem.c:106) ==7903== by 0x4A2B1F4: g_slice_alloc (gslice.c:1069) ==7903== by 0x4A51322: UnknownInlinedFun (gvariant-core.c:486) ==7903== by 0x4A51322: UnknownInlinedFun (gvariant-core.c:624) ==7903== by 0x4A51322: g_variant_builder_end (gvariant.c:3718) ==7903== by 0x4C2FEC1: parse_value_from_blob.isra.0 (gdbusmessage.c:1866) ==7903== by 0x4C2FE8F: parse_value_from_blob.isra.0 (gdbusmessage.c:1766) ==7903== by 0x4C2FF37: parse_value_from_blob.isra.0 (gdbusmessage.c:1850) ==7903== by 0x4BF93A7: g_dbus_message_new_from_blob (gdbusmessage.c:2226) ==7903== by 0x4C09334: _g_dbus_worker_do_read_cb (gdbusprivate.c:750) ==7903== by 0x4B9EA79: g_task_return_now (gtask.c:1219) ==7903== by 0x4B9EABC: complete_in_idle_cb (gtask.c:1233) ==7903== by 0x4A0774A: g_idle_dispatch (gmain.c:5848) Signed-off-by: Louis-Alexis Eyraud --- libmm-glib/mm-modem-3gpp-profile-manager.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libmm-glib') diff --git a/libmm-glib/mm-modem-3gpp-profile-manager.c b/libmm-glib/mm-modem-3gpp-profile-manager.c index 67ae2928..29cf1cfe 100644 --- a/libmm-glib/mm-modem-3gpp-profile-manager.c +++ b/libmm-glib/mm-modem-3gpp-profile-manager.c @@ -154,7 +154,7 @@ build_list_results (GVariant *dictionaries, n = g_variant_iter_n_children (&iter); if (n > 0) { - g_autoptr(GVariant) dictionary = NULL; + GVariant* dictionary = NULL; while ((dictionary = g_variant_iter_next_value (&iter))) { MM3gppProfile *profile = NULL; @@ -167,6 +167,7 @@ build_list_results (GVariant *dictionaries, saved_error = g_steal_pointer (&inner_error); } else profiles = g_list_append (profiles, profile); + g_variant_unref (dictionary); } } -- cgit v1.2.3-70-g09d2