From 8cd564b2b8ee9e345a8fb1b42058ca5b7533f9f7 Mon Sep 17 00:00:00 2001 From: Scott Vokes Date: Fri, 17 Jan 2025 13:34:31 -0500 Subject: [PATCH] Fix a bug in the CDATA interpreter's bitset checking. Because of the for loop init condition, this was checking bits `1 << 1..64` in every word -- it was unintentionally ignoring the least significant bit. It should check `1 << 0..64`. --- src/libfsm/print/cdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libfsm/print/cdata.c b/src/libfsm/print/cdata.c index 447dfb48c..1f209df7c 100644 --- a/src/libfsm/print/cdata.c +++ b/src/libfsm/print/cdata.c @@ -861,7 +861,7 @@ generate_interpreter(FILE *f, const struct cdata_config *config, const struct fs fprintf(f, "\tfor (size_t w_i = 0; w_i < %zu; w_i++) {\n", eager_output_words); fprintf(f, "\t\tconst uint64_t w = uncommitted_eager_output_buf[w_i];\n"); fprintf(f, "\t\tif (w == 0) { continue; }\n"); - fprintf(f, "\t\tfor (size_t bit = 1; bit < 64; bit++) {\n"); + fprintf(f, "\t\tfor (size_t bit = 0; bit < 64; bit++) {\n"); fprintf(f, "\t\t\tif (w & ((uint64_t)1 << bit)) {\n"); fprintf(f, "\t\t\t\tconst uint64_t id = %s_dfa_data.eager_output_ids[64*w_i + bit];\n", prefix); fprintf(f, "\t\t\t\teager_output_buf[id/64] |= ((uint64_t)1 << (id & 63));\n");