mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-04 23:28:08 +02:00
dhcp: don't destroy old value before setting new in nm_dhcp_client_set_effective_client_id()
Of course, the old "priv->effective_client_id" and the new
"client_id" instances are truly separate, that is, they don't
share data, and destroying "priv->effective_client_id" before
taking a reference on "client_id" causes no problem.
It's still a code smell. It makes the function unnecessarily unsafe
under (very unusual) circumstances.
(cherry picked from commit a3e4f764d1)
This commit is contained in:
parent
1f30005d5e
commit
919d66f049
1 changed files with 4 additions and 3 deletions
|
|
@ -274,8 +274,9 @@ nm_dhcp_client_create_options_dict(NMDhcpClient *self, gboolean static_keys)
|
|||
gboolean
|
||||
nm_dhcp_client_set_effective_client_id(NMDhcpClient *self, GBytes *client_id)
|
||||
{
|
||||
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self);
|
||||
gs_free char *tmp_str = NULL;
|
||||
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self);
|
||||
gs_free char *tmp_str = NULL;
|
||||
gs_unref_bytes GBytes *client_id_to_free = NULL;
|
||||
|
||||
g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE);
|
||||
g_return_val_if_fail(!client_id || g_bytes_get_size(client_id) >= 2, FALSE);
|
||||
|
|
@ -285,7 +286,7 @@ nm_dhcp_client_set_effective_client_id(NMDhcpClient *self, GBytes *client_id)
|
|||
if (nm_g_bytes_equal0(priv->effective_client_id, client_id))
|
||||
return FALSE;
|
||||
|
||||
g_bytes_unref(priv->effective_client_id);
|
||||
client_id_to_free = g_steal_pointer(&priv->effective_client_id);
|
||||
priv->effective_client_id = nm_g_bytes_ref(client_id);
|
||||
|
||||
_LOGT("%s: set effective %s",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue