Issue #599: Fix the backwards check in lh_table_insert_w_hash() that was preventing adding more than 11 objects.

Add a test to check for this too.
This commit is contained in:
Eric Haszlakiewicz
2020-05-10 03:32:19 +00:00
parent 45b6416652
commit 519dfe1591
3 changed files with 31 additions and 1 deletions

View File

@@ -582,7 +582,7 @@ int lh_table_insert_w_hash(struct lh_table *t, const void *k, const void *v, con
if (t->count >= t->size * LH_LOAD_FACTOR) {
/* Avoid signed integer overflow with large tables. */
int new_size = INT_MAX / 2 < t->size ? t->size * 2 : INT_MAX;
int new_size = (t->size > INT_MAX / 2) ? INT_MAX : (t->size * 2);
if (t->size == INT_MAX || lh_table_resize(t, new_size) != 0)
return -1;
}