libnm: fix leak with self assignment in nm_connection_add_setting()
We must consume the reference, like we would in the other case. Interestingly, I am unable to reproduce a case where valgrind would complain about the leak. But it is there nonetheless. Fixes: 0a22f4e4905c ('libnm: refactor tracking of NMSetting in NMConnection')
This commit is contained in:
@@ -202,8 +202,10 @@ _nm_connection_add_setting(NMConnection *connection, NMSetting *setting)
|
|||||||
priv = NM_CONNECTION_GET_PRIVATE(connection);
|
priv = NM_CONNECTION_GET_PRIVATE(connection);
|
||||||
|
|
||||||
s_old = priv->settings[setting_info->meta_type];
|
s_old = priv->settings[setting_info->meta_type];
|
||||||
if (s_old == setting)
|
if (s_old == setting) {
|
||||||
|
g_object_unref(s_old);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
priv->settings[setting_info->meta_type] = setting;
|
priv->settings[setting_info->meta_type] = setting;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user