cli: fix leak in print_wifi_connection()
Found by Coverity:
Error: RESOURCE_LEAK (CWE-772): [#def297] [important]
NetworkManager-1.31.3/src/nmcli/devices.c:4610: alloc_fn: Storage is returned from allocation function "nm_utils_ssid_to_utf8".
NetworkManager-1.31.3/src/nmcli/devices.c:4610: var_assign: Assigning: "ssid" = storage returned from "nm_utils_ssid_to_utf8(g_bytes_get_data(ssid_bytes, NULL), g_bytes_get_size(ssid_bytes))".
NetworkManager-1.31.3/src/nmcli/devices.c:4612: noescape: Resource "ssid" is not freed or pointed-to in "g_print".
NetworkManager-1.31.3/src/nmcli/devices.c:4642: noescape: Resource "ssid" is not freed or pointed-to in "string_append_mecard".
NetworkManager-1.31.3/src/nmcli/devices.c:4654: leaked_storage: Variable "ssid" going out of scope leaks the storage it points to.
# 4652|
# 4653| g_print("\n");
# 4654|-> }
# 4655|
# 4656| static gboolean
Fixes: 7061341a41
('cli: add "nmcli d wifi show"')
This commit is contained in:
@@ -4599,7 +4599,7 @@ print_wifi_connection(const NmcConfig *nmc_config, NMConnection *connection)
|
||||
const char * psk = NULL;
|
||||
const char * type = NULL;
|
||||
GBytes * ssid_bytes;
|
||||
char * ssid;
|
||||
gs_free char * ssid = NULL;
|
||||
GString * string;
|
||||
|
||||
s_wireless = nm_connection_get_setting_wireless(connection);
|
||||
|
Reference in New Issue
Block a user