Merge pull request #4968 from ThomasWaldmann/fix-hashindex-set-1.0

fix bug in hashindex_set on resize, fixes #4829 (1.0-maint backport)
This commit is contained in:
TW 2020-03-05 22:36:06 +01:00 committed by GitHub
commit 387646864f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -449,6 +449,16 @@ hashindex_set(HashIndex *index, const void *key, const void *value)
if(!hashindex_resize(index, index->num_buckets)) {
return 0;
}
/* we have just built a fresh hashtable and removed all tombstones,
* so we only have EMPTY or USED buckets, but no DELETED ones any more.
*/
idx = hashindex_index(index, key);
while(!BUCKET_IS_EMPTY(index, idx)) {
idx++;
if (idx >= index->num_buckets){
idx -= index->num_buckets;
}
}
}
}
ptr = BUCKET_ADDR(index, idx);