diff -r ec62453fc8a6 -r 1ecf4dbbc60c src/hash_map.c --- a/src/hash_map.c Fri Dec 20 21:25:33 2024 +0100 +++ b/src/hash_map.c Sat Dec 21 21:03:28 2024 +0100 @@ -30,6 +30,7 @@ #include #include +#include struct cx_hash_map_element_s { /** A pointer to the next element in the current bucket. */ @@ -451,6 +452,10 @@ if (map->collection.size > ((hash_map->bucket_count * 3) >> 2)) { size_t new_bucket_count = (map->collection.size * 5) >> 1; + if (new_bucket_count < hash_map->bucket_count) { + errno = EOVERFLOW; + return 1; + } struct cx_hash_map_element_s **new_buckets = cxCalloc( map->collection.allocator, new_bucket_count, sizeof(struct cx_hash_map_element_s *)