Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There may be a bug in "ht-internal.h" #1312

Open
AClumsyDog opened this issue Jul 21, 2022 · 1 comment
Open

There may be a bug in "ht-internal.h" #1312

AClumsyDog opened this issue Jul 21, 2022 · 1 comment

Comments

@AClumsyDog
Copy link

In function 'HT_GROW', there may be a bug.

    do {                                                                \
      new_len = name##_PRIMES[++prime_idx];                             \
      new_load_limit = (unsigned)(load*new_len);                        \
    } while (new_load_limit <= size &&                                  \
             prime_idx < (int)name##_N_PRIMES);    

When prime_idx grows to N_PRIMES - 1,next prime_idx becomes N_PRIMES. This is a problem with visiting PRIMES.

@azat
Copy link
Member

azat commented Jul 22, 2022

Indeed, nice catch!
Can you send a PR with a patch (it will be great if you will add some regression test for this, see test/ directory for examples)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants