1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-08 08:58:27 +03:00

tree-wide: use free_and_str*dup() more

This commit is contained in:
David Tardon 2023-05-24 14:47:36 +02:00
parent d6f2cd671c
commit a73e5eb94c
3 changed files with 9 additions and 12 deletions

View File

@ -590,10 +590,9 @@ _public_ int sd_bus_get_name_creds(
if (r < 0)
return r;
free(c->label);
c->label = strndup(p, sz);
if (!c->label)
return -ENOMEM;
r = free_and_strndup(&c->label, p, sz);
if (r < 0)
return r;
c->mask |= SD_BUS_CREDS_SELINUX_CONTEXT;

View File

@ -124,10 +124,9 @@ _public_ int sd_pid_get_cgroup(pid_t pid, char **cgroup) {
* cgroup, let's return the "/" in the public APIs instead, as
* that's easier and less ambiguous for people to grok. */
if (isempty(c)) {
free(c);
c = strdup("/");
if (!c)
return -ENOMEM;
r = free_and_strdup(&c, "/");
if (r < 0)
return r;
}

View File

@ -712,10 +712,9 @@ int veth_extra_parse(char ***l, const char *p) {
if (r < 0)
return r;
if (r == 0 || !ifname_valid(b)) {
free(b);
b = strdup(a);
if (!b)
return -ENOMEM;
r = free_and_strdup(&b, a);
if (r < 0)
return r;
}
if (p)