diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-14 11:45:20 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-14 14:45:25 +0000 |
commit | 57747dfc454c33f83daebbe1007502c718593836 (patch) | |
tree | e016751661adae65ee51826be270414f6a641557 /contrib/libucl | |
parent | 9f0a4220decbb0adaf8aa63d506cf01c55e3204c (diff) | |
download | rspamd-57747dfc454c33f83daebbe1007502c718593836.tar.gz rspamd-57747dfc454c33f83daebbe1007502c718593836.zip |
[Fix] Fix deletion from hash
Diffstat (limited to 'contrib/libucl')
-rw-r--r-- | contrib/libucl/ucl_hash.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/contrib/libucl/ucl_hash.c b/contrib/libucl/ucl_hash.c index ce2a4fdb5..92c8b3933 100644 --- a/contrib/libucl/ucl_hash.c +++ b/contrib/libucl/ucl_hash.c @@ -368,6 +368,7 @@ ucl_hash_delete (ucl_hash_t* hashlin, const ucl_object_t *obj) { khiter_t k; struct ucl_hash_elt *elt; + size_t i; if (hashlin == NULL) { return; @@ -380,8 +381,15 @@ ucl_hash_delete (ucl_hash_t* hashlin, const ucl_object_t *obj) k = kh_get (ucl_hash_caseless_node, h, obj); if (k != kh_end (h)) { elt = &kh_value (h, k); + i = elt->ar_idx; kv_del (const ucl_object_t *, hashlin->ar, elt->ar_idx); kh_del (ucl_hash_caseless_node, h, k); + + /* Update subsequent elts */ + for (; i < hashlin->ar.n; i ++) { + elt = &kh_value (h, i); + elt->ar_idx --; + } } } else { @@ -390,8 +398,15 @@ ucl_hash_delete (ucl_hash_t* hashlin, const ucl_object_t *obj) k = kh_get (ucl_hash_node, h, obj); if (k != kh_end (h)) { elt = &kh_value (h, k); + i = elt->ar_idx; kv_del (const ucl_object_t *, hashlin->ar, elt->ar_idx); kh_del (ucl_hash_node, h, k); + + /* Update subsequent elts */ + for (; i < hashlin->ar.n; i ++) { + elt = &kh_value (h, i); + elt->ar_idx --; + } } } } |