Fix temp_key being stale on key re-insert

See issue #992 and pull request #993.
This commit is contained in:
Macoy Madson 2021-05-31 19:51:39 -07:00
parent c9064e3176
commit 63e4ada98c

View File

@ -1378,6 +1378,8 @@ void *stbds_hmput_key(void *a, size_t elemsize, void *key, size_t keysize, int m
if (bucket->hash[i] == hash) {
if (stbds_is_key_equal(raw_a, elemsize, key, keysize, keyoffset, mode, bucket->index[i])) {
stbds_temp(a) = bucket->index[i];
if (mode >= STBDS_HM_STRING)
stbds_temp_key(a) = * (char **) ((char *) raw_a + elemsize*bucket->index[i] + keyoffset);
return STBDS_ARR_TO_HASH(a,elemsize);
}
} else if (bucket->hash[i] == 0) {