mirror of
https://github.com/json-c/json-c.git
synced 2026-04-04 21:09:06 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user