diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-02-08 18:27:54 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-02-10 10:30:34 +0100 |
commit | af1def5bfaaf37f32aa76b30294fb2795db7948e (patch) | |
tree | bb858c3e28c86e67ab4374078d9a43f4095a2313 | |
parent | d79f60e3dc1fde0ba3de58c167869a212e1f9042 (diff) | |
download | ModemManager-af1def5bfaaf37f32aa76b30294fb2795db7948e.tar.gz |
libmm-glib: set clear func by default in the MMModemPortInfo array
So that we don't leak the port names allocated within each
MMModemPortInfo.
==261== 672 bytes in 84 blocks are definitely lost in loss record 7,314 of 7,383
==261== at 0x402C51E: malloc (vg_replace_malloc.c:299)
==261== by 0x4484878: g_malloc (gmem.c:94)
==261== by 0x449D51D: g_strdup (gstrfuncs.c:363)
==261== by 0x44B5B73: g_variant_dup_string (gvariant.c:1529)
==261== by 0x44B945E: g_variant_valist_get_nnp (gvariant.c:4775)
==261== by 0x44B945E: g_variant_valist_get_leaf (gvariant.c:4945)
==261== by 0x44B945E: g_variant_valist_get (gvariant.c:5126)
==261== by 0x44B922C: g_variant_valist_get (gvariant.c:5161)
==261== by 0x44B9FC9: g_variant_get_va (gvariant.c:5388)
==261== by 0x44BA3C5: g_variant_get_child (gvariant.c:5486)
==261== by 0x6613FA8: mm_common_ports_variant_to_garray (mm-common-helpers.c:238)
==261== by 0x6601AB9: ensure_internal_ports (mm-modem.c:766)
==261== by 0x6603E42: mm_modem_peek_ports (mm-modem.c:825)
==261== by 0x65CD94D: owns_port (nm-modem-broadband.c:196)
Reported-by: Piotr Figiel <p.figiel@camlintechnologies.com>
(cherry picked from commit 91613543d595f8d345a8725746b6f77a821173a8)
-rw-r--r-- | libmm-glib/mm-common-helpers.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c index 4b784da0c..d86205651 100644 --- a/libmm-glib/mm-common-helpers.c +++ b/libmm-glib/mm-common-helpers.c @@ -219,6 +219,12 @@ mm_common_sms_storages_garray_to_variant (GArray *array) return mm_common_sms_storages_array_to_variant (NULL, 0); } +static void +clear_modem_port_info (MMModemPortInfo *info) +{ + g_free (info->name); +} + GArray * mm_common_ports_variant_to_garray (GVariant *variant) { @@ -232,6 +238,7 @@ mm_common_ports_variant_to_garray (GVariant *variant) if (n > 0) { array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemPortInfo), n); + g_array_set_clear_func (array, (GDestroyNotify) clear_modem_port_info); for (i = 0; i < n; i++) { MMModemPortInfo info; |