Commit 963b72bc authored by Beniamino Galvani's avatar Beniamino Galvani

ifnet: fix memory leaks

Fix memory leaks in ifnet plugin and tests, and re-enable valgrind for
tests.
parent 74a0e74d
...@@ -679,7 +679,7 @@ make_ip4_setting (NMConnection *connection, ...@@ -679,7 +679,7 @@ make_ip4_setting (NMConnection *connection,
/* DNS searches */ /* DNS searches */
value = ifnet_get_data (conn_name, "dns_search"); value = ifnet_get_data (conn_name, "dns_search");
if (value) { if (value) {
char *stripped = g_strdup (value); gs_free char *stripped = g_strdup (value);
char **searches = NULL; char **searches = NULL;
strip_string (stripped, '"'); strip_string (stripped, '"');
......
...@@ -501,13 +501,13 @@ GList * ...@@ -501,13 +501,13 @@ GList *
ifnet_get_connection_names (void) ifnet_get_connection_names (void)
{ {
GList *names = g_hash_table_get_keys (conn_table); GList *names = g_hash_table_get_keys (conn_table);
GList *result = NULL; GList *iter, *result = NULL;
while (names) { for (iter = names; iter; iter = iter->next) {
if (!ignore_connection_name (names->data)) if (!ignore_connection_name (iter->data))
result = g_list_prepend (result, names->data); result = g_list_prepend (result, iter->data);
names = names->next;
} }
g_list_free (names); g_list_free (names);
return g_list_reverse (result); return g_list_reverse (result);
} }
......
...@@ -34,7 +34,7 @@ test_ifnet_LDFLAGS = \ ...@@ -34,7 +34,7 @@ test_ifnet_LDFLAGS = \
test_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la test_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la
#@VALGRIND_RULES@ @VALGRIND_RULES@
TESTS = test-ifnet TESTS = test-ifnet
endif endif
......
...@@ -346,7 +346,7 @@ test_delete_connection (void) ...@@ -346,7 +346,7 @@ test_delete_connection (void)
static void static void
test_missing_config (void) test_missing_config (void)
{ {
GError *error = NULL; gs_free_error GError *error = NULL;
NMConnection *connection; NMConnection *connection;
connection = ifnet_update_connection_from_config_block ("eth8", NULL, &error); connection = ifnet_update_connection_from_config_block ("eth8", NULL, &error);
......
...@@ -77,8 +77,10 @@ add_security (GHashTable *security) ...@@ -77,8 +77,10 @@ add_security (GHashTable *security)
/* Hex format begins with " */ /* Hex format begins with " */
is_hex_ssid = (ssid[0] != '"'); is_hex_ssid = (ssid[0] != '"');
if ((value = g_hash_table_lookup (security, "disabled")) != NULL) { if ((value = g_hash_table_lookup (security, "disabled")) != NULL) {
if (strcmp (value, "1") == 0) if (strcmp (value, "1") == 0) {
destroy_security (security);
return NULL; return NULL;
}
} }
/* Default priority is 1 */ /* Default priority is 1 */
...@@ -111,6 +113,7 @@ add_security (GHashTable *security) ...@@ -111,6 +113,7 @@ add_security (GHashTable *security)
static void static void
add_key_value (GHashTable * network, gchar * line) add_key_value (GHashTable * network, gchar * line)
{ {
gpointer orig_key, orig_value;
gchar **key_value; gchar **key_value;
if (g_str_has_prefix (line, "network={")) if (g_str_has_prefix (line, "network={"))
...@@ -133,6 +136,14 @@ add_key_value (GHashTable * network, gchar * line) ...@@ -133,6 +136,14 @@ add_key_value (GHashTable * network, gchar * line)
&& !g_str_has_prefix (key_value[0], "wep_key") && !g_str_has_prefix (key_value[0], "wep_key")
&& strcmp (key_value[0], "ssid") != 0) && strcmp (key_value[0], "ssid") != 0)
strip_string (key_value[1], '"'); strip_string (key_value[1], '"');
/* This sucks */
if (g_hash_table_lookup_extended (network, key_value[0], &orig_key, &orig_value)) {
g_hash_table_remove (network, orig_key);
g_free (orig_key);
g_free (orig_value);
}
g_hash_table_insert (network, g_strdup (key_value[0]), g_hash_table_insert (network, g_strdup (key_value[0]),
g_strdup (key_value[1])); g_strdup (key_value[1]));
g_strfreev (key_value); g_strfreev (key_value);
......
...@@ -440,3 +440,11 @@ ...@@ -440,3 +440,11 @@
fun:start_thread fun:start_thread
fun:clone fun:clone
} }
{
_btrfs_io_clone
Memcheck:Param
ioctl(generic)
fun:ioctl
fun:btrfs_reflink_with_progress
...
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment