network: make both search_domains and route_domains allocated on DBus call

This commit is contained in:
Yu Watanabe
2021-11-26 20:20:06 +09:00
parent 0843ec6c44
commit 1f65aa3a58
+9 -7
View File
@@ -195,9 +195,16 @@ int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_
if (r < 0)
return r;
search_domains = ordered_set_new(&string_hash_ops_free);
if (!search_domains)
return -ENOMEM;
route_domains = ordered_set_new(&string_hash_ops_free);
if (!route_domains)
return -ENOMEM;
for (;;) {
_cleanup_free_ char *str = NULL;
OrderedSet **domains;
const char *name;
int route_only;
@@ -219,12 +226,7 @@ int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_
if (r < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid search domain %s", name);
domains = route_only ? &route_domains : &search_domains;
r = ordered_set_ensure_allocated(domains, &string_hash_ops_free);
if (r < 0)
return r;
r = ordered_set_consume(*domains, TAKE_PTR(str));
r = ordered_set_consume(route_only ? route_domains : search_domains, TAKE_PTR(str));
if (r == -EEXIST)
continue;
if (r < 0)