diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-09-10 13:45:18 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-09-10 13:45:18 +0200 |
commit | 452e90ba72f57c44b44f9940ac951d2fde417583 (patch) | |
tree | 0ee72b911906ea1830bd353c400785098b0c6b41 /filter | |
parent | 1127887a8b111dab18c592f1f3f575920f38bfe3 (diff) |
Filter: Fix crash with 'where' filters and function calls
The old 'where' code computed size value incorrectly, which leads
to invalid instruction lines and filter errors or crashes.
Diffstat (limited to 'filter')
-rw-r--r-- | filter/f-util.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/filter/f-util.c b/filter/f-util.c index e61949f2..410999a6 100644 --- a/filter/f-util.c +++ b/filter/f-util.c @@ -32,33 +32,12 @@ filter_name(const struct filter *filter) struct filter *f_new_where(struct f_inst *where) { - struct f_inst acc = { - .fi_code = FI_DIE, - .lineno = ifs->lino, - .size = 1, - .i_FI_DIE = { .fret = F_ACCEPT, }, - }; - - struct f_inst rej = { - .fi_code = FI_DIE, - .lineno = ifs->lino, - .size = 1, - .i_FI_DIE = { .fret = F_REJECT, }, - }; - - struct f_inst i = { - .fi_code = FI_CONDITION, - .lineno = ifs->lino, - .size = 3 + where->size, - .i_FI_CONDITION = { - .f1 = where, - .f2 = &acc, - .f3 = &rej, - }, - }; + struct f_inst *cond = f_new_inst(FI_CONDITION, where, + f_new_inst(FI_DIE, F_ACCEPT), + f_new_inst(FI_DIE, F_REJECT)); struct filter *f = cfg_allocz(sizeof(struct filter)); - f->root = f_linearize(&i); + f->root = f_linearize(cond); return f; } |