diff options
author | Daniel Mack <github@zonque.org> | 2016-01-27 13:35:18 +0100 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2016-01-27 13:35:18 +0100 |
commit | fdb4ee00f022863ceee923b196f9c6dd536db9e2 (patch) | |
tree | 647aae3aa21c2e22073fc895f39a2c171e052a99 /src/systemctl/systemctl.c | |
parent | 1cdc94482302cca88e0a7282bbc161c1d77c381c (diff) | |
parent | a464cf80110f0c7424f688ffaa4ec0a8a19f9720 (diff) |
Merge pull request #2445 from poettering/various-fixes
A number of fixes
Diffstat (limited to 'src/systemctl/systemctl.c')
-rw-r--r-- | src/systemctl/systemctl.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 94c99c4d91..73f5710b9c 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -2658,14 +2658,25 @@ static int expand_names(sd_bus *bus, char **names, const char* suffix, char ***r if (!strv_isempty(globs)) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_free_ UnitInfo *unit_infos = NULL; + size_t allocated, n; r = get_unit_list(bus, NULL, globs, &unit_infos, 0, &reply); if (r < 0) return r; - for (i = 0; i < r; i++) - if (strv_extend(&mangled, unit_infos[i].id) < 0) + n = strv_length(mangled); + allocated = n + 1; + + for (i = 0; i < r; i++) { + if (!GREEDY_REALLOC(mangled, allocated, n+2)) + return log_oom(); + + mangled[n] = strdup(unit_infos[i].id); + if (!mangled[n]) return log_oom(); + + mangled[++n] = NULL; + } } *ret = mangled; |