2007-11-21 Dan Williams <dcbw@redhat.com>

* libnm-util/nm-setting-vpn-properties.c
		- (set_property): must deep-copy the given settings hash, otherwise
			double-free errors occur when the setting is disposed of



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3102 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2007-11-21 05:46:50 +00:00
parent a2c202ed8d
commit f2b002c3de
2 changed files with 23 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2007-11-21 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-setting-vpn-properties.c
- (set_property): must deep-copy the given settings hash, otherwise
double-free errors occur when the setting is disposed of
2007-11-21 Dan Williams <dcbw@redhat.com>
* src/vpn-manager/nm-vpn-act-request.h

View file

@ -75,6 +75,19 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_setting_vpn_properties_parent_class)->finalize (object);
}
static void
copy_hash (gpointer key, gpointer data, gpointer user_data)
{
NMSettingVPNProperties *setting = NM_SETTING_VPN_PROPERTIES (user_data);
GValue *src_val = (GValue *) data;
GValue *copy_val;
copy_val = g_slice_new0 (GValue);
g_value_init (copy_val, G_VALUE_TYPE (src_val));
g_value_copy (src_val, copy_val);
g_hash_table_insert (setting->data, g_strdup (key), copy_val);
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
@ -85,7 +98,10 @@ set_property (GObject *object, guint prop_id,
case PROP_DATA:
if (setting->data)
g_hash_table_destroy (setting->data);
setting->data = g_value_dup_boxed (value);
/* Must make a deep copy of the hash table here... */
setting->data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nm_gvalue_destroy);
g_hash_table_foreach (g_value_get_boxed (value), copy_hash, setting);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);