diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2023-04-23 15:06:59 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-23 15:06:59 -0400 |
| commit | 3eefea924914b8ff48391e24b475b769afa7c45b (patch) | |
| tree | be185da9c64dcde20eddd9144b714e27e3808b6a /lib/typesafe.c | |
| parent | 97ed21a5467d1df5f34e93e29359bfd00360b6b6 (diff) | |
| parent | 5523a505f4bd6ce57f951ccb0cc7b9b29a963d7c (diff) | |
Merge pull request #13350 from opensourcerouting/typesafe-fixes-20230421
lib: typesafe shenanigans
Diffstat (limited to 'lib/typesafe.c')
| -rw-r--r-- | lib/typesafe.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/typesafe.c b/lib/typesafe.c index 0da35d0f8c..c077447985 100644 --- a/lib/typesafe.c +++ b/lib/typesafe.c @@ -85,6 +85,15 @@ void typesafe_hash_grow(struct thash_head *head) uint32_t newsize = head->count, i, j; uint8_t newshift, delta; + /* note hash_grow is called after head->count++, so newsize is + * guaranteed to be >= 1. So the minimum argument to builtin_ctz + * below is 2, which returns 1, and that makes newshift >= 2. + * + * Calling hash_grow with a zero head->count would result in a + * malformed hash table that has tabshift == 1. + */ + assert(head->count > 0); + hash_consistency_check(head); newsize |= newsize >> 1; |
