diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2018-06-27 09:57:41 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-09-14 17:29:05 +0200 |
commit | 6a9d2740acdfb12dd427b3243775fcf4c34c535b (patch) | |
tree | d13cb7f9509c911d19ecddeefd8c28f2951dde5b /clients/common | |
parent | 74a3d184b0cd0d8fc62d104ac666396da9f07e06 (diff) | |
download | NetworkManager-6a9d2740acdfb12dd427b3243775fcf4c34c535b.tar.gz |
clients: fix memory leak when parsing routes
The new hash table should destroy elements stolen from the hash table
returned by nm_utils_parse_variant_attributes().
Fixes: d0949141203f6a546317277ed788ea114d401dd8
(cherry picked from commit 31bda1b8373c71ecb41d8208aa2bc9c88999d988)
Diffstat (limited to 'clients/common')
-rw-r--r-- | clients/common/nm-meta-setting-desc.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c index 8c27779e26..f794c67b2b 100644 --- a/clients/common/nm-meta-setting-desc.c +++ b/clients/common/nm-meta-setting-desc.c @@ -192,11 +192,20 @@ _parse_ip_route (int family, return NULL; } - if (!attrs) - attrs = g_hash_table_new (nm_str_hash, g_str_equal); + if (!attrs) { + attrs = g_hash_table_new_full (nm_str_hash, + g_str_equal, + g_free, + (GDestroyNotify) g_variant_unref); + } g_hash_table_iter_init (&iter, tmp_attrs); while (g_hash_table_iter_next (&iter, (gpointer *) &iter_key, (gpointer *) &iter_value)) { + + /* need to sink the reference, because nm_utils_parse_variant_attributes() returns + * floating refs. */ + g_variant_ref_sink (iter_value); + if (!nm_ip_route_attribute_validate (iter_key, iter_value, family, NULL, error)) { g_prefix_error (error, "%s: ", iter_key); g_hash_table_unref (tmp_attrs); |