1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* parse.y (rb_id2str): fill klass of returned string as rb_cString.

some strings are allocated before rb_cString is created.
  This prevents a "called on terminated object" error by
  ObjectSpace.each_object(Module) {|m| p m.name }.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-12-24 19:25:45 +00:00
parent edb8eee236
commit c94a89a739
2 changed files with 19 additions and 4 deletions

View file

@ -1,3 +1,10 @@
Tue Dec 25 04:23:32 2007 Tanaka Akira <akr@fsij.org>
* parse.y (rb_id2str): fill klass of returned string as rb_cString.
some strings are allocated before rb_cString is created.
This prevents a "called on terminated object" error by
ObjectSpace.each_object(Module) {|m| p m.name }.
Tue Dec 25 03:51:55 2007 Koichi Sasada <ko1@atdot.net>
* compile.c (iseq_compile_each): fix stack consistency bug.

16
parse.y
View file

@ -9039,8 +9039,12 @@ rb_id2str(ID id)
}
}
if (st_lookup(global_symbols.id_str, id, &data))
return (VALUE)data;
if (st_lookup(global_symbols.id_str, id, &data)) {
VALUE str = (VALUE)data;
if (RBASIC(str)->klass == 0)
RBASIC(str)->klass = rb_cString;
return str;
}
if (is_attrset_id(id)) {
ID id2 = (id & ~ID_SCOPE_MASK) | ID_LOCAL;
@ -9053,8 +9057,12 @@ rb_id2str(ID id)
str = rb_str_dup(str);
rb_str_cat(str, "=", 1);
rb_intern_str(str);
if (st_lookup(global_symbols.id_str, id, &data))
return (VALUE)data;
if (st_lookup(global_symbols.id_str, id, &data)) {
VALUE str = (VALUE)data;
if (RBASIC(str)->klass == 0)
RBASIC(str)->klass = rb_cString;
return str;
}
}
return 0;
}