mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-02 17:00:14 +01:00
core: rework string handling in enslave_slave()
Coverity doesn't like the previous code: Error: RESOURCE_LEAK (CWE-772): [#def34] [important] NetworkManager-1.31.5/src/core/devices/team/nm-device-team.c:835: alloc_fn: Storage is returned from allocation function "g_strdup". NetworkManager-1.31.5/src/core/devices/team/nm-device-team.c:835: noescape: Resource "g_strdup(config)" is not freed or pointed-to in "g_strdelimit". NetworkManager-1.31.5/src/core/devices/team/nm-device-team.c:835: leaked_storage: Failing to save or free storage allocated by "g_strdup(config)" leaks it. # 833| char *sanitized_config; # 834| # 835|-> sanitized_config = g_strdelimit(g_strdup(config), "\r\n", ' '); # 836| err = teamdctl_port_config_update_raw(priv->tdc, slave_iface, sanitized_config); # 837| g_free(sanitized_config); Maybe this works better.
This commit is contained in:
parent
ff9f2d27ec
commit
174f7bd27b
1 changed files with 4 additions and 4 deletions
|
|
@ -829,12 +829,12 @@ enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gbool
|
|||
"enslaved team port %s config not changed, not connected to teamd",
|
||||
slave_iface);
|
||||
} else {
|
||||
int err;
|
||||
char *sanitized_config;
|
||||
gs_free char *sanitized_config = NULL;
|
||||
int err;
|
||||
|
||||
sanitized_config = g_strdelimit(g_strdup(config), "\r\n", ' ');
|
||||
sanitized_config = g_strdup(config);
|
||||
g_strdelimit(sanitized_config, "\r\n", ' ');
|
||||
err = teamdctl_port_config_update_raw(priv->tdc, slave_iface, sanitized_config);
|
||||
g_free(sanitized_config);
|
||||
if (err != 0) {
|
||||
_LOGE(LOGD_TEAM,
|
||||
"failed to update config for port %s (err=%d)",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue