1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 16:59:03 +03:00

dbus-unit: check userdata before obtaining data

This commit is contained in:
Yu Watanabe 2018-05-11 18:12:12 +09:00
parent cb7f88fcf4
commit d1d8547137

View File

@ -99,7 +99,7 @@ static int property_get_dependencies(
void *userdata, void *userdata,
sd_bus_error *error) { sd_bus_error *error) {
Hashmap *h = *(Hashmap**) userdata; Hashmap **h = userdata;
Iterator j; Iterator j;
Unit *u; Unit *u;
void *v; void *v;
@ -107,12 +107,13 @@ static int property_get_dependencies(
assert(bus); assert(bus);
assert(reply); assert(reply);
assert(h);
r = sd_bus_message_open_container(reply, 'a', "s"); r = sd_bus_message_open_container(reply, 'a', "s");
if (r < 0) if (r < 0)
return r; return r;
HASHMAP_FOREACH_KEY(v, u, h, j) { HASHMAP_FOREACH_KEY(v, u, *h, j) {
r = sd_bus_message_append(reply, "s", u->id); r = sd_bus_message_append(reply, "s", u->id);
if (r < 0) if (r < 0)
return r; return r;
@ -146,7 +147,7 @@ static int property_get_requires_mounts_for(
void *userdata, void *userdata,
sd_bus_error *error) { sd_bus_error *error) {
Hashmap *h = *(Hashmap**) userdata; Hashmap **h = userdata;
const char *p; const char *p;
Iterator j; Iterator j;
void *v; void *v;
@ -154,12 +155,13 @@ static int property_get_requires_mounts_for(
assert(bus); assert(bus);
assert(reply); assert(reply);
assert(h);
r = sd_bus_message_open_container(reply, 'a', "s"); r = sd_bus_message_open_container(reply, 'a', "s");
if (r < 0) if (r < 0)
return r; return r;
HASHMAP_FOREACH_KEY(v, p, h, j) { HASHMAP_FOREACH_KEY(v, p, *h, j) {
r = sd_bus_message_append(reply, "s", p); r = sd_bus_message_append(reply, "s", p);
if (r < 0) if (r < 0)
return r; return r;