libnm: always finalize direct properties in NMSetting base class

Certain properties need to release memory when destroying the NMSetting.
For "direct" properties, we have all the information we need to do that
generically in the NMSetting base class. In practice, this only concerns
string properties.

See _finalize_direct() in "nm-setting.c".

However, if the NMSetting base class takes care of freeing the strings,
then the subclasses must not also unref the variable (to avoid double free).
Previously, subclasses had to opt-in for the base class to indicate that
they are fine with that.

Now, let the base class always handle it. We only need to make sure that
classes that implement direct string properties don't also try to free
the values during destruction.
This commit is contained in:
Thomas Haller
2021-10-23 20:58:27 +02:00
parent 2aa1fdd2bf
commit 989a6911ba
22 changed files with 11 additions and 121 deletions

View File

@@ -1569,9 +1569,7 @@ finalize(GObject *object)
{
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE(object);
g_free(priv->mac_address);
g_free(priv->multicast_router);
g_free(priv->group_address);
g_free(priv->vlan_protocol);
g_ptr_array_unref(priv->vlans);