summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2012-07-28 06:44:55 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2012-07-28 06:44:55 -0700
commit919a84771bfb9d535d56d68a49e60567ecda2253 (patch)
treea98ce561a8f0aa2a711f101c72e42a4295ff5a79
parent5d58bd0d78de41d707cdbde3f48908da01d34ec6 (diff)
parentb48cfea73619f0fbf64324209f5fa5d7cc725856 (diff)
downloadmruby-919a84771bfb9d535d56d68a49e60567ecda2253.tar.gz
mruby-919a84771bfb9d535d56d68a49e60567ecda2253.zip
Merge pull request #398 from masamitsu-murase/modify_hash_shift
Protect deleted key and value from GC.
-rw-r--r--src/hash.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/hash.c b/src/hash.c
index dacef4713..04e8c60be 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -568,7 +568,9 @@ mrb_hash_shift(mrb_state *mrb, mrb_value hash)
if (!kh_exist(h,k)) continue;
delKey = kh_key(h,k);
+ mrb_gc_protect(mrb, delKey);
delVal = mrb_hash_delete_key(mrb, hash, delKey);
+ mrb_gc_protect(mrb, delVal);
return mrb_assoc_new(mrb, delKey, delVal);
}