summaryrefslogtreecommitdiffhomepage
path: root/src/hash.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-06-27 09:34:40 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2019-06-27 09:35:58 +0900
commit23783a44300a39efbbc312a6ca22fe61d94db857 (patch)
treef7f29693f307774a2845e108290332d3fde70f74 /src/hash.c
parent9bc7edd6736f3563cfb127038f68bc319f3929f0 (diff)
downloadmruby-23783a44300a39efbbc312a6ca22fe61d94db857.tar.gz
mruby-23783a44300a39efbbc312a6ca22fe61d94db857.zip
Skip copying delete keys in a hash; fix #4534
Diffstat (limited to 'src/hash.c')
-rw-r--r--src/hash.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/hash.c b/src/hash.c
index b4d96251c..ac6a7cd56 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -240,7 +240,7 @@ ht_compact(mrb_state *mrb, htable *t)
if (!seg->next && i >= t->last_len) {
goto exit;
}
- if (mrb_undef_p(k)) { /* found delete key */
+ if (mrb_undef_p(k)) { /* found deleted key */
if (seg2 == NULL) {
seg2 = seg;
i2 = i;
@@ -543,6 +543,7 @@ ht_copy(mrb_state *mrb, htable *t)
mrb_value key = seg->e[i].key;
mrb_value val = seg->e[i].val;
+ if (mrb_undef_p(key)) continue; /* skip deleted key */
if ((seg->next == NULL) && (i >= t->last_len)) {
return t2;
}