summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorCarson McDonald <[email protected]>2013-06-26 08:37:28 -0400
committerCarson McDonald <[email protected]>2013-06-26 08:37:28 -0400
commit1d4b26ecfc9500f7de48d24e8a1ba1ec2cc5eeac (patch)
treec47ecec4ed8937dc90503f00b617b3a96fe132e6
parentcf840c1d05f33f0e32f86508bdeae880fd059a5e (diff)
downloadmruby-1d4b26ecfc9500f7de48d24e8a1ba1ec2cc5eeac.tar.gz
mruby-1d4b26ecfc9500f7de48d24e8a1ba1ec2cc5eeac.zip
Add arena save/restore around use of hash KEY.
-rw-r--r--src/hash.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/hash.c b/src/hash.c
index 5d78a6ea7..9b8c546b9 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -145,7 +145,9 @@ mrb_hash_set(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value val) /* mr
k = kh_get(ht, h, key);
if (k == kh_end(h)) {
/* expand */
+ int ai = mrb_gc_arena_save(mrb);
k = kh_put(ht, h, KEY(key));
+ mrb_gc_arena_restore(mrb, ai);
}
kh_value(h, k) = val;
@@ -169,7 +171,9 @@ mrb_hash_dup(mrb_state *mrb, mrb_value hash)
for (k = kh_begin(h); k != kh_end(h); k++) {
if (kh_exist(h,k)) {
+ int ai = mrb_gc_arena_save(mrb);
ret_k = kh_put(ht, ret_h, KEY(kh_key(h,k)));
+ mrb_gc_arena_restore(mrb, ai);
kh_val(ret_h, ret_k) = kh_val(h,k);
}
}