static int hello_callback(sd_bus_message *reply, void *userdata, sd_bus_error *error) {
const char *s;
+ char *t;
sd_bus *bus;
int r;
if (!service_name_is_valid(s) || s[0] != ':')
return -EBADMSG;
- bus->unique_name = strdup(s);
- if (!bus->unique_name)
+ t = strdup(s);
+ if (!t)
return -ENOMEM;
+ free_and_replace(bus->unique_name, t);
+
if (bus->state == BUS_HELLO) {
bus_set_state(bus, BUS_RUNNING);
int bus_set_address_system_remote(sd_bus *b, const char *host) {
_cleanup_free_ char *e = NULL;
- char *m = NULL, *c = NULL;
+ char *m = NULL, *c = NULL, *a;
assert(b);
assert(host);
return -ENOMEM;
}
- b->address = strjoin("unixexec:path=ssh,argv1=-xT,argv2=--,argv3=", e, ",argv4=systemd-stdio-bridge", c);
- if (!b->address)
+ a = strjoin("unixexec:path=ssh,argv1=-xT,argv2=--,argv3=", e, ",argv4=elogind-stdio-bridge", c);
+ if (!a)
return -ENOMEM;
+ free_and_replace(b->address, a);
+
return 0;
}
int bus_set_address_system_machine(sd_bus *b, const char *machine) {
_cleanup_free_ char *e = NULL;
+ char *a;
assert(b);
assert(machine);
if (!e)
return -ENOMEM;
- b->address = strjoin("x-machine-unix:machine=", e);
- if (!b->address)
+ a = strjoin("x-machine-unix:machine=", e);
+ if (!a)
return -ENOMEM;
+ free_and_replace(b->address, a);
+
return 0;
}