iwd: Fix the leaks in get_agent_request_network_path

Don't request new copies of strings from g_variant_get() to avoid
leaking memory as pointed out by Thomas Haller.

Fixes: dc0e31fb70 ('iwd: Add the wifi.iwd.autoconnect setting')
This commit is contained in:
Andrew Zaborowski 2021-02-12 11:04:26 +01:00 committed by Thomas Haller
parent e23bafe5d5
commit 5ccb8ce17a
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1282,15 +1282,13 @@ get_agent_request_network_path(GDBusMethodInvocation *invocation)
const char *network_path = NULL;
if (nm_streq(method_name, "RequestPassphrase"))
g_variant_get(params, "(o)", &network_path);
g_variant_get(params, "(&o)", &network_path);
else if (nm_streq(method_name, "RequestPrivateKeyPassphrase"))
g_variant_get(params, "(o)", &network_path);
g_variant_get(params, "(&o)", &network_path);
else if (nm_streq(method_name, "RequestUserNameAndPassword"))
g_variant_get(params, "(o)", &network_path);
else if (nm_streq(method_name, "RequestUserPassword")) {
const char *user;
g_variant_get(params, "(os)", &network_path, &user);
}
g_variant_get(params, "(&o)", &network_path);
else if (nm_streq(method_name, "RequestUserPassword"))
g_variant_get(params, "(&os)", &network_path, NULL);
return network_path;
}