diff options
author | Maria Matejka <mq@ucw.cz> | 2023-06-22 16:07:28 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2023-06-22 16:12:17 +0200 |
commit | 1499a335f6f44a0fd85365e404c2a11842d7f75c (patch) | |
tree | 2ad5e68447921b6c4360479751d34532de1999c4 | |
parent | ac7341a18146bf0f0b2c60477c4292a9cd428a87 (diff) |
Filter: Fixed segfault when a case option had an empty block
Thanks to Kobayashi_Bairuo <noc@tohunet.com> for reporting.
-rw-r--r-- | filter/decl.m4 | 6 | ||||
-rw-r--r-- | filter/f-inst.c | 1 | ||||
-rw-r--r-- | filter/test.conf | 25 |
3 files changed, 26 insertions, 6 deletions
diff --git a/filter/decl.m4 b/filter/decl.m4 index 5b35b672..7c863bdc 100644 --- a/filter/decl.m4 +++ b/filter/decl.m4 @@ -200,7 +200,7 @@ FID_INTERPRET_BODY()') # Executing another filter line. This replaces the recursion # that was needed in the former implementation. m4_define(LINEX, `FID_INTERPRET_EXEC()LINEX_($1)FID_INTERPRET_NEW()return $1 FID_INTERPRET_BODY()') -m4_define(LINEX_, `do { +m4_define(LINEX_, `do if ($1) { fstk->estk[fstk->ecnt].pos = 0; fstk->estk[fstk->ecnt].line = $1; fstk->estk[fstk->ecnt].ventry = fstk->vcnt; @@ -227,9 +227,7 @@ if (!f_same(f1->fl$1, f2->fl$1)) return 0; FID_ITERATE_BODY()m4_dnl if (whati->fl$1) BUFFER_PUSH(fit->lines) = whati->fl$1; FID_INTERPRET_EXEC()m4_dnl -do { if (whati->fl$1) { - LINEX_(whati->fl$1); -} } while(0) +LINEX_(whati->fl$1) FID_INTERPRET_NEW()m4_dnl return whati->f$1 FID_INTERPRET_BODY()') diff --git a/filter/f-inst.c b/filter/f-inst.c index e4b47ff4..33436853 100644 --- a/filter/f-inst.c +++ b/filter/f-inst.c @@ -1327,7 +1327,6 @@ FID_HIC(,break,return NULL); } } - /* It is actually possible to have t->data NULL */ LINEX(t->data); } diff --git a/filter/test.conf b/filter/test.conf index 600c551e..e9e3af89 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -39,6 +39,18 @@ bt_test_same(onef, oneg, 1); bt_test_same(onef, twof, 0); /* + * Testing filter corner cases + * --------------------------- + */ + +function t_nothing() {} +bt_test_suite(t_nothing, "Testing nothing"); + +function t_metanothing() { t_nothing(); } +bt_test_suite(t_metanothing, "Testing meta nothing"); + + +/* * Testing boolean expressions * --------------------------- */ @@ -76,6 +88,14 @@ bt_test_suite(t_bool, "Testing boolean expressions"); * ---------------- */ +function aux_t_int(int t; int u) +{ + case t { + 1: {} + else: {} + } +} + define four = 4; define xyzzy = (120+10); define '1a-a1' = (xyzzy-100); @@ -120,7 +140,10 @@ function t_int() else: bt_assert(false); } - + aux_t_int(1, 2); + aux_t_int(1, 3); + aux_t_int(2, 3); + aux_t_int(2, 2); } bt_test_suite(t_int, "Testing integers"); |