diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-07-09 06:14:41 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-07-09 06:14:41 +0000 |
commit | 76a929a7fca3c84630574e4daa9dab7a96b04fc8 (patch) | |
tree | a9cd02b421dd1e70fd8e478589f93ae94af9af23 /vm_method.c | |
parent | 37f018fdf52d0f75d66d467055f992dee1c0a420 (diff) | |
download | ruby-76a929a7fca3c84630574e4daa9dab7a96b04fc8.tar.gz |
* parse.y: change Symbol <-> ID relationship to avoid
exposing IDs from collectable symbols.
[Bug #10014]
Now, rb_check_id() returns 0 if corresponding symbol is
pinned dynamic symbol.
There is remaining intern_cstr_without_pindown(), it can return
IDs from collectable symbols. We must be careful to use it
(only used in parse.y). I think it should be removed if
it does not have impact for performance.
* parse.y:
add:
* STATIC_SYM2ID()
* STATIC_ID2SYM()
rename:
* rb_pin_dynamic_symbol() -> dsymbol_pindown()
* internal.h:
remove:
* rb_check_id_without_pindown()
* rb_sym2id_without_pindown()
add:
* rb_check_symbol()
* rb_check_symbol_cstr()
* load.c: use rb_check_id() or rb_check_id_cstr().
* object.c: ditto.
* struct.c: ditto.
* thread.c: ditto.
* vm_method.c: ditto.
* string.c (sym_find): use only rb_check_symbol().
* sprintf.c (rb_str_format): use rb_check_symbol_cstr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/vm_method.c b/vm_method.c index 966fc419b6..cb450b1910 100644 --- a/vm_method.c +++ b/vm_method.c @@ -797,7 +797,7 @@ rb_mod_remove_method(int argc, VALUE *argv, VALUE mod) for (i = 0; i < argc; i++) { VALUE v = argv[i]; - ID id = rb_check_id_without_pindown(&v); + ID id = rb_check_id(&v); if (!id) { rb_name_error_str(v, "method `%s' not defined in %s", RSTRING_PTR(v), rb_class2name(mod)); @@ -1008,7 +1008,7 @@ rb_mod_undef_method(int argc, VALUE *argv, VALUE mod) int i; for (i = 0; i < argc; i++) { VALUE v = argv[i]; - ID id = rb_check_id_without_pindown(&v); + ID id = rb_check_id(&v); if (!id) { rb_method_name_error(mod, v); } @@ -1048,7 +1048,7 @@ rb_mod_undef_method(int argc, VALUE *argv, VALUE mod) static VALUE rb_mod_method_defined(VALUE mod, VALUE mid) { - ID id = rb_check_id_without_pindown(&mid); + ID id = rb_check_id(&mid); if (!id || !rb_method_boundp(mod, id, 1)) { return Qfalse; } @@ -1062,7 +1062,7 @@ static VALUE check_definition(VALUE mod, VALUE mid, rb_method_flag_t noex) { const rb_method_entry_t *me; - ID id = rb_check_id_without_pindown(&mid); + ID id = rb_check_id(&mid); if (!id) return Qfalse; me = rb_method_entry(mod, id, 0); if (me) { @@ -1691,7 +1691,7 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj) ID id; rb_scan_args(argc, argv, "11", &mid, &priv); - if (!(id = rb_check_id_without_pindown(&mid))) { + if (!(id = rb_check_id(&mid))) { if (!rb_method_basic_definition_p(CLASS_OF(obj), idRespond_to_missing)) { VALUE args[2]; args[0] = ID2SYM(rb_to_id(mid)); |