diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-03-24 00:22:38 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-03-24 00:34:33 +0900 |
commit | 7bb55ed099f611ec7077db69684a6cb93d42dc70 (patch) | |
tree | cd2897955fe511057a393a450ebeeeb856b6f131 /src/shared/condition.c | |
parent | 16b4623620acdccb232392901074a61e360aa2a4 (diff) | |
download | systemd-7bb55ed099f611ec7077db69684a6cb93d42dc70.tar.gz |
util: fix condition_free_list_type()
This fixes a bug introduced by c4f58deab56282cd438922203287cb073b861513.
Closes oss-fuzz#13878, oss-fuzz#13882, oss-fuzz#13884, oss-fuzz#13886, and
oss-fuzz#13888.
Diffstat (limited to 'src/shared/condition.c')
-rw-r--r-- | src/shared/condition.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/shared/condition.c b/src/shared/condition.c index 69d65fffbc..32a90bcea3 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -77,17 +77,17 @@ void condition_free(Condition *c) { free(c); } -Condition* condition_free_list_type(Condition *first, ConditionType type) { - Condition *c, *n, *r = NULL; +Condition* condition_free_list_type(Condition *head, ConditionType type) { + Condition *c, *n; - LIST_FOREACH_SAFE(conditions, c, n, first) - if (type < 0 || c->type == type) + LIST_FOREACH_SAFE(conditions, c, n, head) + if (type < 0 || c->type == type) { + LIST_REMOVE(conditions, head, c); condition_free(c); - else if (!r) - r = c; + } - assert(type >= 0 || !r); - return r; + assert(type >= 0 || !head); + return head; } static int condition_test_kernel_command_line(Condition *c) { |