Skip to content

Commit

Permalink
bugfix: The range is min..max inclusive, so add 1.
Browse files Browse the repository at this point in the history
If min and max are exactly 64 states apart the upper value was getting
silently dropped due to an incorrect `words` value here.

One of the patterns in the PCRE suite triggers this:

    ./re -rpcre '(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))' "caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"

This should match, but did not.
  • Loading branch information
silentbicycle authored and katef committed Sep 11, 2023
1 parent c1e1282 commit 6eff0f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libfsm/determinise.c
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ sort_and_dedup_dst_buf(fsm_state_t *buf, size_t *used)
* and deduplicates in the process. Add 1 to avoid a zero-
* zero-length array error if QSORT_CUTOFF is 0. */
uint64_t bitset[QSORT_CUTOFF/64 + 1];
const size_t words = u64bitset_words(max - min);
const size_t words = u64bitset_words(max - min + 1);
memset(bitset, 0x00, words * sizeof(bitset[0]));

for (size_t i = 0; i < orig_used; i++) {
Expand Down

0 comments on commit 6eff0f9

Please sign in to comment.