* 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
This commit is contained in:
ko1 2014-07-09 06:14:41 +00:00
parent 37f018fdf5
commit 76a929a7fc
11 changed files with 246 additions and 151 deletions

View file

@ -353,7 +353,7 @@ rb_path_to_class(VALUE pathname)
}
while (*p) {
while (*p && *p != ':') p++;
id = rb_check_id_cstr_without_pindown(pbeg, p-pbeg, enc);
id = rb_check_id_cstr(pbeg, p-pbeg, enc);
if (p[0] == ':') {
if (p[1] != ':') goto undefined_class;
p += 2;
@ -1404,7 +1404,7 @@ VALUE
rb_obj_remove_instance_variable(VALUE obj, VALUE name)
{
VALUE val = Qnil;
const ID id = rb_check_id_without_pindown(&name);
const ID id = rb_check_id(&name);
st_data_t n, v;
struct st_table *iv_index_tbl;
st_data_t index;
@ -1920,7 +1920,7 @@ rb_public_const_get_at(VALUE klass, ID id)
VALUE
rb_mod_remove_const(VALUE mod, VALUE name)
{
const ID id = rb_check_id_without_pindown(&name);
const ID id = rb_check_id(&name);
if (!id) {
if (rb_is_const_name(name)) {
@ -2569,7 +2569,7 @@ rb_mod_class_variables(int argc, const VALUE *argv, VALUE mod)
VALUE
rb_mod_remove_cvar(VALUE mod, VALUE name)
{
const ID id = rb_check_id_without_pindown(&name);
const ID id = rb_check_id(&name);
st_data_t val, n = id;
if (!id) {