Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Protect deleted key and value from GC. #398

Merged
merged 1 commit into from

2 participants

@masamitsu-murase

In mrb_hash_shift, delKey and delVal may be swept by GC, because GC sometimes occurs in mrb_assoc_new.

@matz matz merged commit 919a847 into mruby:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 28, 2012
  1. @masamitsu-murase
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 0 deletions.
  1. +2 −0  src/hash.c
View
2  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);
}
Something went wrong with that request. Please try again.