2007-08-16 Dan Williams <dcbw@redhat.com>

* libnm-glib/nm-client.c
		- (nm_client_init): create VPN connections hash table with key free
			function
		- (proxy_vpn_connection_added): VPN connections hash table key should
			be a duplicated value, not the same memory address as the VPN
			connection name.  This is because the VPN connection name could
			potentially be freed and set to something else during the lifetime
			of the NMVPNConnection object.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2706 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2007-08-16 22:54:22 +00:00
parent 1214ece853
commit 9c9ae6abff
2 changed files with 15 additions and 7 deletions

View file

@ -1,3 +1,14 @@
2007-08-16 Dan Williams <dcbw@redhat.com>
* libnm-glib/nm-client.c
- (nm_client_init): create VPN connections hash table with key free
function
- (proxy_vpn_connection_added): VPN connections hash table key should
be a duplicated value, not the same memory address as the VPN
connection name. This is because the VPN connection name could
potentially be freed and set to something else during the lifetime
of the NMVPNConnection object.
2007-08-16 Tambet Ingo <tambet@gmail.com>
* src/ppp-manager/nm-ppp-manager.c (pppd_child_setup): Implement.

View file

@ -64,7 +64,9 @@ nm_client_init (NMClient *client)
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
priv->vpn_connections = g_hash_table_new (g_str_hash, g_str_equal);
priv->vpn_connections = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
NULL);
priv->vpn_state = NM_VPN_CONNECTION_STATE_UNKNOWN;
}
@ -551,7 +553,6 @@ proxy_vpn_connection_added (DBusGProxy *proxy, char *name, gpointer user_data)
NMClient *client = NM_CLIENT (user_data);
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
NMVPNConnection *connection;
const char * vpn_name;
if (g_hash_table_lookup (priv->vpn_connections, name))
return;
@ -565,11 +566,7 @@ proxy_vpn_connection_added (DBusGProxy *proxy, char *name, gpointer user_data)
return;
}
/* Use the vpn connection object's name to insert into the hash table
* so that it's lifetime is the same as the vpn connection object.
*/
vpn_name = nm_vpn_connection_get_name (connection);
g_hash_table_insert (priv->vpn_connections, (char *) vpn_name, connection);
g_hash_table_insert (priv->vpn_connections, g_strdup (name), connection);
g_signal_emit (client, signals[VPN_CONNECTION_ADDED], 0, connection);
}