summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-11-16 19:10:56 +0100
committerThomas Haller <thaller@redhat.com>2022-11-16 21:15:09 +0100
commit3e3b62958665db5694389d477b507a76ee053b3a (patch)
tree45f80e8b6480fdd354e013f3d0713e89a6e5afa5
parent3b2eb689f3da1e957216b6106382b9a46bae266f (diff)
downloadNetworkManager-3e3b62958665db5694389d477b507a76ee053b3a.tar.gz
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')
-rw-r--r--src/libnm-core-impl/nm-connection.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libnm-core-impl/nm-connection.c b/src/libnm-core-impl/nm-connection.c
index 7685a681c4..1314d6b580 100644
--- a/src/libnm-core-impl/nm-connection.c
+++ b/src/libnm-core-impl/nm-connection.c
@@ -202,8 +202,10 @@ _nm_connection_add_setting(NMConnection *connection, NMSetting *setting)
priv = NM_CONNECTION_GET_PRIVATE(connection);
s_old = priv->settings[setting_info->meta_type];
- if (s_old == setting)
+ if (s_old == setting) {
+ g_object_unref(s_old);
return;
+ }
priv->settings[setting_info->meta_type] = setting;