gparam: Remove unsynchronized write to g_type field

GValue g_type field is used for synchronization with g_once_init_enter,
and so it should be written to only with g_once_init_leave.

Replace structure copy with memcpy that copies the one remaining field
of GValue, i.e., data array.
This commit is contained in:
Tomasz Miąsko 2019-02-21 00:00:00 +00:00
parent d72192f69b
commit fba7f7e097

View File

@ -1561,8 +1561,7 @@ g_param_spec_get_default_value (GParamSpec *pspec)
g_param_value_set_default (pspec, &default_value); g_param_value_set_default (pspec, &default_value);
/* store all but the type */ /* store all but the type */
default_value.g_type = 0; memcpy (priv->default_value.data, default_value.data, sizeof (default_value.data));
priv->default_value = default_value;
g_once_init_leave (&priv->default_value.g_type, pspec->value_type); g_once_init_leave (&priv->default_value.g_type, pspec->value_type);
} }