mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
strv: fix counting in strv_env_delete()
This commit is contained in:
23
src/strv.c
23
src/strv.c
@@ -482,8 +482,8 @@ static bool env_match(const char *t, const char *pattern) {
|
||||
}
|
||||
|
||||
char **strv_env_delete(char **x, unsigned n_lists, ...) {
|
||||
size_t n = 0, i = 0;
|
||||
char **l, **k, **r, **j;
|
||||
size_t n, i = 0;
|
||||
char **k, **r;
|
||||
va_list ap;
|
||||
|
||||
/* Deletes every entry from x that is mentioned in the other
|
||||
@@ -491,29 +491,34 @@ char **strv_env_delete(char **x, unsigned n_lists, ...) {
|
||||
|
||||
n = strv_length(x);
|
||||
|
||||
if (!(r = new(char*, n+1)))
|
||||
r = new(char*, n+1);
|
||||
if (!r)
|
||||
return NULL;
|
||||
|
||||
STRV_FOREACH(k, x) {
|
||||
va_start(ap, n_lists);
|
||||
unsigned v;
|
||||
|
||||
va_start(ap, n_lists);
|
||||
for (v = 0; v < n_lists; v++) {
|
||||
char **l, **j;
|
||||
|
||||
for (i = 0; i < n_lists; i++) {
|
||||
l = va_arg(ap, char**);
|
||||
STRV_FOREACH(j, l)
|
||||
if (env_match(*k, *j))
|
||||
goto delete;
|
||||
goto skip;
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
if (!(r[i++] = strdup(*k))) {
|
||||
r[i] = strdup(*k);
|
||||
if (!r[i]) {
|
||||
strv_free(r);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
i++;
|
||||
continue;
|
||||
|
||||
delete:
|
||||
skip:
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user