Merge pull request #4969 from ThomasWaldmann/fix-hashindex-set

fix bug in hashindex_set on resize, fixes #4829
This commit is contained in:
TW 2020-03-01 18:56:03 +01:00 committed by GitHub
commit 0a4cc48735
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -586,6 +586,16 @@ hashindex_set(HashIndex *index, const unsigned char *key, const unsigned char *v
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 = start_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);